CMailMessage::CopyMessage Method  
 
BOOL CopyMessage(
  CMailMessage* pMessage  
);

The CopyMessage method copies the contents of the specified message.

Parameters

pMessage
A pointer to a CMailMessage object which contains the message to be copied. If this argument is NULL, the current message contents will be cleared.

Return Value

If the message was successfully copied, the method will return a non-zero value. If the method fails, it will return value of zero. To get extended error information, call GetLastError.

Remarks

This method is used to create a copy of the specified message, replacing the current message contents. Note that this method creates a duplicate of the message referenced by the pMessage object, and any subsequent changes to the contents of the original message will not be reflected in the copy of that message.

Example

CMailMessage *pMessage1 = new CMailMessage();
CMailMessage *pMessage2 = new CMailMessage();

// Compose a test message
pMessage1->ComposeMessage(_T("Bob Jones <bob@example.com>"),
                          _T("Tom Smith <tom@example.com>"),
                          NULL,
                          _T("This is a test message"),
                          _T("This is a test, this is only a test."));

// Create a copy of the message and change the subject
// The original subject in pMessage1 remains unchanged
if (pMessage2->CopyMessage(pMessage1))
{
    CString &strSubject;
    if (pMessage2->GetHeader(0, _T("Subject"), strSubject))
    {
        strSubject = _T("Re: ") + strSubject;
        pMessage2->SetHeader(0, _T("Subject"), strSubject);
    }
}

Requirements

Minimum Desktop Platform: Windows 7 (Service Pack 1)
Minimum Server Platform: Windows Server 2008 R2 (Service Pack 1)
Header File: cstools10.h
Import Library: csmsgv10.lib

See Also

ClearMessage, ComposeMessage