Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

How to create a SMS with attachment in inbox

From Wiki
Jump to: navigation, search
Article Metadata

文章
xueyw 在 20 Sep 2007 创建
最后由 hamishwillee 在 15 Dec 2011 编辑
CMsvSession* messageSession;
CClientMtmRegistry* registry;
TFileName details;
TFileName description;
TFileName fileName;
TEntryInfoHolder infoHolder;
 
messageSession = CMsvSession::OpenSyncL(*this);
CleanupStack::PushL(messageSession);
 
registry = CClientMtmRegistry::NewL( *messageSession );
CleanupStack::PushL( registry );
 
infoHolder.messageSession = messageSession;
infoHolder.iEntryId = 0; // No entry yet !
CleanupStack::PushL( TCleanupItem( DeleteEntry, &infoHolder ) );
 
// Subject
_LIT(KSub, "InterGrafx");
details.Copy( KSub() );
 
// Description
description.Copy( igpFileName );
 
// Get message inbox
CMsvEntry* inbox=messageSession->GetEntryL( KMsvGlobalInBoxIndexEntryIdValue );
CleanupStack::PushL( inbox );
 
TMsvEntry newEntry;
 
 
// Child entry of inbox
// TMsvEntry
#ifdef __UIQV21__
newEntry.iMtm = TUid::Uid( KUidMsgTypeBT );
#endif
 
#ifdef __S60V12__
newEntry.iMtm = TUid::Uid( KUidMsgTypeBt );
#endif //
#ifdef __S60V22__
newEntry.iMtm = TUid::Uid( KUidMsgTypeBt.iUid );
#endif //__S60V22__
newEntry.SetVisible( EFalse );
newEntry.SetInPreparation( ETrue );
newEntry.iType = KUidMsvMessageEntry;
newEntry.iServiceId = KMsvUnknownServiceIndexEntryId;
newEntry.iDate.HomeTime();
newEntry.iSize = 120553;//todo
newEntry.iDetails.Set( details );
newEntry.iDescription.Set( description );
 
// For bio
// For future usage
//newEntry.iBioType = 0x101F3CD9;
//newEntry.iMtmData3 = 1;
//KMmsMessageMRetrieveConf | KMmsMessageMobileTerminated; // this defines MT message
//newEntry.iMtmData1 = 0;
//newEntry.iMtmData2 = 0;
//TUid aTypeUid;
//aTypeUid.iUid = 0x10000F6A;
//newEntry.iType = aTypeUid;
//TUid aMtmUid;
//aMtmUid.iUid = 0x10001262;
//newEntry.iMtm = aMtmUid;
 
inbox->CreateL(newEntry);
infoHolder.iEntryId=newEntry.Id();
 
CClientMtmRegistry* mtmReg = CClientMtmRegistry::NewL( *messageSession );
CleanupStack::PushL( mtmReg );
 
// Child entry of inbox
// CMsvEntry
CMsvEntry* entry = messageSession->GetEntryL( newEntry.Id() );
CleanupStack::PushL( entry );
 
CBaseMtm *mtm = mtmReg->NewMtmL( entry->Entry().iMtm );
// takes ownership
// The attachment will belong to it
mtm->SetCurrentEntryL( entry );
CleanupStack::Pop(); // entry
CleanupStack::PushL( mtm );
 
// Create an empty attachment
// On return, we get values of attachmentId, tempfileName
TFileName tempfileName;
TMsvId attachmentId;
mtm->CreateAttachmentL( attachmentId, tempfileName );
 
// Construct the path of the file to be created as attachment
HBufC* completeFilePath = HBufC::NewLC( 500 );
TPtr completeFilePathPtr = completeFilePath->Des();
completeFilePathPtr.Append( tempfileName );
completeFilePathPtr.Append( description );


Links

Best regards http://www.devdiv.com/

This page was last modified on 15 December 2011, at 10:20.
203 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×