diff -r 43e37759235e -r 51a74ef9ed63 Symbian3/SDK/Source/GUID-D8D698FF-08CD-56B4-A6BF-E185A25F6988.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/SDK/Source/GUID-D8D698FF-08CD-56B4-A6BF-E185A25F6988.dita Wed Mar 31 11:11:55 2010 +0100 @@ -0,0 +1,119 @@ + + + + + +Retrieving +and modifying attachments to messagesThe messaging framework allows you to retrieve and modify attachments +to messages. +

Attachments may +be retrieved and modified after they have been added to a message.

+ +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 an MMsvAttachmentManager attachment +manager for the message entry, using CMsvStore::AttachmentManagerL(). + + +Find how many attachments a message entry has using the MMsvAttachmentManager::AttachmentCount() function. + + +Get attachment attributes using the appropriate CMsvAttachment functions. +. + + +Get attachment information using the MMsvAttachmentManager::GetattachmentL() function. + + +Retrieval and +modification example

The following code uses the MMsvAttachmentManager::AttachmentCount() and GetattachmentL() functions to get attachment information. It then calls the various CMsvAttachment accessor +functions to get the attachment attributes, and to access the attachment file +itself:

void CFoo::GetAttachmentInfoL(MMsvAttachmentManager& attManager) + { + // get number of attachments + TInt numAttach = attManager.AttachmentCount(); + if ( numAttach == 0 ) + { // no attachments + return; + } + + // Get attachment attributes for the first attachment (index 0) + CMsvAttachment* attachInfo = attManager.GetAttachmentInfoL(0); + + // Ownership of attachInfo is transferred to the caller - so push it onto the CleanupStack + CleanupStack::PushL(attachInfo); + + // Get attachment's name + const TDesC& attachName = attachInfo->AttachmentName(); + + // Get attachment's size + TInt attachSize = attachInfo->Size(); + + // Get attachment's type + CMsvAttachment::TMsvAttachmentType attachType = attachInfo->Type(); + + // Get MIME type + const TDesC8& attachMType = attachInfo->MimeType(); + + // Get completeness flag + TBool complete = attachInfo->Complete(); + + ... + + // Destroy attachInfo when finished. + CleanupStack::PopAndDestroy(attachInfo); + }

You can modify attachment information for an existing +attachment using the ModifyattachmentL() function. The +attachment information object passed in replaces the existing attachment information +object.

void CFoo::ModifyAttachmentInfoL(CMsvEntry& aEntry) + { + // Get the store + CMsvStore* store = aEntry.EditStoreL(); + CleanupStack::PushL(store); + + MMsvAttachmentManager& attManager = store->AttachmentManagerL(); + + // Get number of attachments + TInt numAttach = attManager.AttachmentCount(); + if ( numAttach == 0 ) + { // no attachments + CleanupStack::PopAndDestroy() ; // store + return; + } + + // Get attachment attributes for the first attachment (index 0) + CMsvAttachment* attachment = attManager.GetAttachmentInfoL(0); + CleanupStack::PushL( attachment ) ; + + // Rename the file + TRequestStatus status; + _LIT(KFileName, "hello.txt"); + + attachment->SetAttachmentNameL(KFileName); + attachment->SetComplete(EFalse); + + // Modify attachment info + attManager.ModifyAttachmentInfoL(attachment, status); + + // Wait for request to complete + User::WaitForRequest(status); + attachment->SetComplete(ETrue); + + store->CommitL(); + + CleanupStack::PopAndDestroy(2, store); // attachment, store + }
+
+Messaging +Attachments Tutorial +Messaging +Framework Overview +
\ No newline at end of file