The messaging framework allows you to add attachments to messages.
A message attachment, once it has been created, must be added to its message in a separate procedure explained in this document.
MMsvAttachmentManager
functions that modify attachments for an entry are asynchronous,
so a request must be called with an active object implementation.
//* Active object request function to add an attachment. Arguments: aEntry - entry to make attachment for aAttachPath - path of file to attach aSize - size of attachment in bytes */ void CFoo::AttachFileL(CMsvEntry& aEntry, const TFileName& aAttachPath, TInt aSize) { ... // Wait for request to complete User::WaitForRequest(status); CleanupStack::PopAndDestroy(store); }
Get the details of the message to which you want to add an attachment using CMsvEntry::EditStoreL().
This function returns CMsvStore in writable mode.// Get store CMsvStore* store = aEntry.EditStoreL(); CleanupStack::PushL(store);
Get an MMsvAttachmentManager
attachment manager for the message
entry, using CMsvStore::AttachmentManagerL().
// Get attachment manager from the entry's store MMsvAttachmentManager& attManager = store->AttachmentManagerL();
CMsvAttachment::NewL()
function.
// Create a new attachment attributes object CMsvAttachment* attachment = CMsvAttachment::NewL(CMsvAttachment::EMsvFile); CleanupStack::PushL(attachment);
CMsvAttachment
class.
// Set the attachment name and size attributes TParse fparse; User::LeaveIfError(fparse.Set(aAttachPath,NULL,NULL)); attachment->SetAttachmentNameL(fparse.NameAndExt()); attachment->SetSize(aSize);
MMsvAttachmentManager::AddAttachmentL()
function.
MMsvAttachmentManager::AddLinkedAttachmentL()
function.
CObexHeaderList::ExportToAttachmentL()
function. Headers
can be retrieved using the CObexHeaderList::ImportFromAttachmentL()
function.
TRequestStatus status; // Ownership of attachment will transfer to attachManager CleanupStack::Pop(attachment); // Add the attachment attManager.AddAttachmentL(aAttachPath, attachment, status);
You now have an attachment added to its message.
You can now retrieve and modify the message attachment.