--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Symbian3/SDK/Source/GUID-D8D698FF-08CD-56B4-A6BF-E185A25F6988.dita Thu Jan 21 18:18:20 2010 +0000
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
+<!-- This component and the accompanying materials are made available under the terms of the License
+"Eclipse Public License v1.0" which accompanies this distribution,
+and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
+<!-- Initial Contributors:
+ Nokia Corporation - initial contribution.
+Contributors:
+-->
+<!DOCTYPE task
+ PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
+<task id="GUID-D8D698FF-08CD-56B4-A6BF-E185A25F6988" xml:lang="en"><title>Retrieving
+and modifying attachments to messages</title><shortdesc>The messaging framework allows you to retrieve and modify attachments
+to messages. </shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody>
+<context id="GUID-15885C98-AB41-5250-BC54-8FD519FCC2DB"><p>Attachments may
+be retrieved and modified after they have been added to a message. </p> </context>
+<steps id="GUID-8EC42591-32C1-5790-B644-E9DD82F4C767">
+<step id="GUID-7FB4A7D1-965F-5E58-9606-0B2BBDFA9781"><cmd>Get the details
+of the message to which you want to add an attachment using <xref href="GUID-85BBE389-81F7-3E2F-A789-446D9BE2CC49.dita#GUID-85BBE389-81F7-3E2F-A789-446D9BE2CC49/GUID-1864B96D-CB22-3EE1-8E73-023F12C68CB0"><apiname>CMsvEntry::EditStoreL()</apiname></xref>. </cmd>
+<info>This function returns <xref href="GUID-8CB90FA2-A6CF-3FA2-81FF-7D22EFD9C2CE.dita"><apiname>CMsvStore</apiname></xref> in writable mode. </info>
+</step>
+<step id="GUID-BF15138A-9F76-5BD0-A72F-8A125B011CCE"><cmd>Get an <xref href="GUID-4E2B0CEA-1EDA-3452-895D-3CE1B59FD8FD.dita"><apiname>MMsvAttachmentManager</apiname></xref> attachment
+manager for the message entry, using <xref href="GUID-8CB90FA2-A6CF-3FA2-81FF-7D22EFD9C2CE.dita#GUID-8CB90FA2-A6CF-3FA2-81FF-7D22EFD9C2CE/GUID-73CE27F3-855B-3F87-AE11-4B4F2B8F8825"><apiname>CMsvStore::AttachmentManagerL()</apiname></xref>. </cmd>
+</step>
+<step id="GUID-A7041D09-6EA5-54CE-A972-E0D4993C26FC"><cmd/>
+<info>Find how many attachments a message entry has using the <xref href="GUID-4E2B0CEA-1EDA-3452-895D-3CE1B59FD8FD.dita#GUID-4E2B0CEA-1EDA-3452-895D-3CE1B59FD8FD/GUID-BAA9F4CF-E7F8-3644-8C0D-4387BAB7C432"><apiname>MMsvAttachmentManager::AttachmentCount()</apiname></xref> function. </info>
+</step>
+<step id="GUID-A58AFC6B-ADBA-5D3F-824F-A9EBDEBB2A0A"><cmd/>
+<info>Get attachment attributes using the appropriate <xref href="GUID-8C2B9B89-D6B7-3622-AF26-658F53BCB70F.dita"><apiname>CMsvAttachment</apiname></xref> functions.
+. </info>
+</step>
+<step id="GUID-5574C96C-2E2B-55CC-AE8A-BF44CFD76D4B"><cmd/>
+<info>Get attachment information using the <xref href="GUID-4E2B0CEA-1EDA-3452-895D-3CE1B59FD8FD.dita#GUID-4E2B0CEA-1EDA-3452-895D-3CE1B59FD8FD/GUID-256088DF-2FD0-32D9-8EEE-EFAC65A8E9AC"><apiname>MMsvAttachmentManager::GetattachmentL()</apiname></xref> function. </info>
+</step>
+</steps>
+<example id="GUID-94880E70-F23F-5F18-8E0F-A29B99C96E4B"><title>Retrieval and
+modification example</title> <p>The following code uses the <xref href="GUID-4E2B0CEA-1EDA-3452-895D-3CE1B59FD8FD.dita#GUID-4E2B0CEA-1EDA-3452-895D-3CE1B59FD8FD/GUID-BAA9F4CF-E7F8-3644-8C0D-4387BAB7C432"><apiname>MMsvAttachmentManager::AttachmentCount()</apiname></xref> and <xref href="GUID-C7C9E584-2E24-3B65-9E37-F4085F9F7CDB.dita"><apiname>GetattachmentL()</apiname></xref> functions to get attachment information. It then calls the various <xref href="GUID-8C2B9B89-D6B7-3622-AF26-658F53BCB70F.dita"><apiname>CMsvAttachment</apiname></xref> accessor
+functions to get the attachment attributes, and to access the attachment file
+itself: </p> <codeblock id="GUID-FEEB49D7-E9D4-59E7-B9EC-CF87DA3140FE" xml:space="preserve">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);
+ }</codeblock> <p>You can modify attachment information for an existing
+attachment using the <xref href="GUID-ECE58326-D542-3C73-AE6F-959DCF64A875.dita"><apiname>ModifyattachmentL()</apiname></xref> function. The
+attachment information object passed in replaces the existing attachment information
+object. </p> <codeblock id="GUID-DDA08731-A761-5D7F-91DF-41DBC0D16583" xml:space="preserve">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
+ }</codeblock> </example>
+</taskbody><related-links>
+<link href="GUID-1963A487-D6A7-4225-8D0C-EC5FAB746854.dita"><linktext>Messaging
+Attachments Tutorial</linktext></link>
+<link href="GUID-54AB166A-8B24-5065-92AD-5FC1BF3ED89C.dita"><linktext>Messaging
+Framework Overview</linktext></link>
+</related-links></task>
\ No newline at end of file