Creating a message
and setting its contents are done through RSendAsMessage
.
To create a message, use one of the following methods specifying either the
service ID or message type obtained from CSendAsMessageTypes
or CSendAsAccounts
.
The contents of the message can then be set.
void CreateL(RSendAs& aSendAs, TSendAsAccount aAccount);void CreateL(RSendAs& aSendAs, TUid aMessageType);
Add recipients to the message.
The recipient type is one of the TSendAsRecipientType
enumeration
values. The TSendAsRecipientType
parameter of AddRecipientL()
specifies
whether the recipient is of a 'To' , 'Cc' or 'Bcc' type. If the message type
does not support 'Cc' recipients, the recipient is instead treated as a 'To'
recipient. If the 'Bcc' field is not supported, the methods return KErrNotSupported
.
/** Creates a SendAs message @param aMessage An RSendAsMessage reference, used to create a message */ void CSendAs2Example::CreateL( RSendAsMessage& aMessage) { ... aMessage.CreateL(iSendAs, sendAsMtmUid); // Set the body text of this message using a plain descriptor. // The object must have an open message to use this method. aMessage.SetBodyTextL(KBodyText); // The characterset to be set for the message. aMessage.SetCharcterSetL(256); // Add recipients to this message. aMessage.AddRecipientL(KAddress1, KAlias1, RSendAsMessage::ESendAsRecipientTo); aMessage.AddRecipientL(KAddress3, RSendAsMessage::ESendAsRecipientCc); aMessage.AddRecipientL(KAddress4, KAlias2, RSendAsMessage::ESendAsRecipientCc); CMsvEntry* entry = CMsvEntry::NewL(*iSession, KMsvDraftEntryId, TMsvSelectionOrdering(KMsvNoGrouping,EMsvSortByNone,ETrue)); CleanupStack::PushL(entry); // Sets the context to the specified entry. entry->SetEntryL(KMsvDraftEntryId); if(iSelection->Count() >= 1) { entry->SetEntryL((*iSelection)[0]); }; CleanupStack::PopAndDestroy(entry); }
Add attachments, if required.
RSendAsMessage
has the methods to support attachments:
IMPORT_C void AddAttachment(const TDesC& aFilePath, TRequestStatus& aStatus); IMPORT_C void AddAttachment(const TDesC& aFilePath, const TDesC8& aMimeType, TRequestStatus& aStatus); IMPORT_C void AddAttachment(RFile& aFile, const TDesC8& aMimeType, TRequestStatus& aStatus); IMPORT_C void AddAttachment(RFile& aFile, TRequestStatus& aStatus); IMPORT_C void AddLinkedAttachment(const TDesC& aFilePath, const TDesC8& aMimeType, TRequestStatus& aStatus); IMPORT_C void AddLinkedAttachment(const TDesC& aFilePath, TRequestStatus& aStatus); IMPORT_C void CreateAttachmentL(TDes& aFileName, RFile& aAttachmentFile); IMPORT_C void CreateAttachmentL(TDes& aFileName, RFile& aAttachmentFile, const TDesC8& aMimeType);
See Attachment Tutorial for more information on the above methods.
Launch an editor, if required.
The RSendAsMessage::LaunchEditorAndCloseL()
function
allows a client application to launch the editor (as provided by UI MTM) for
the created message. The handle to the message is closed, so it can no longer
be accessed through RSendAsMessage
.
Result of carrying out the task