Groups > Symbian > Symbian general discussion > Reading E-mail attachment




Reading E-mail attachment

Reading E-mail attachment
Wed, 24 Jan 2007 16:03:05 +053
Hi,

I am trying to read an  email attachment for 3rd edition phones in following
way,

CMsvStore* store=aMsvEntry.ReadStoreL();
CleanupStack::PushL(store);

if(aMsvEntry.Entry().Attachment()){

MMsvAttachmentManager& mailAttManager=store->AttachmentManagerL();

TInt attCount=mailAttManager.AttachmentCount();

for(TInt cnt=0;cnt<attCount;cnt++){

TFileName mailFileName(_L("C:\\temp"));

RFile attFile=mailAttManager.GetAttachmentFileL(cnt);
CleanupClosePushL(attFile);

TInt fileSize;
attFile.Size(fileSize);

if(fileSize>0){
HBufC8* fileBuf=HBufC8::NewLC(fileSize);
TPtr8 fileBufPtr(fileBuf->Des());
User::LeaveIfError(attFile.Read(fileBufPtr));

RFile mailFile;
User::LeaveIfError(mailFile.Replace(aFs,mailFileName,EFileWrite));
CleanupClosePushL(mailFile);

User::LeaveIfError(mailFile.Write(*fileBuf));

CleanupStack::PopAndDestroy();
CleanupStack::PopAndDestroy(fileBuf);
}
CleanupStack::PopAndDestroy();
}

}


here,
aMsvEntry.Entry().Attachment() returns that there is an attachment in mail
but value in,
TInt attCount=mailAttManager.AttachmentCount() is always zero i.e. there is
not any attachment in mail even though I have attachment in mail.Because of
this I can't  read email attachment.

Is my way of reading attachment is right? Can anybody tell me how read an
E-mail attachment?

Waiting for reply

Thanks
Yogesh

Post Reply
about | contact