Hi ,
I have problems with getting attachment from the embedded msg in the mail and pst file.
- attachment from the embedded msg:
if we have a msg names “1.msg” which has an embedded msg “2.msg”, then the “2.msg” has an another embedded msg “3.msg” or attachment “3.doc”. So my problem is how to get the attchment of the “2.”msg = MapiMessage.FromFile(“1.msg”);if (msg.Attachments.Count>0){GetAttachment(msg.Attachments)}private void GetAttachment(MapiAttachmentCollection sources){for (int i = 0; i < sources.Count; i++){if (sources[i].ObjectData!= null && sources[i].ObjectData.IsOutlookMessage){MapiMessage m1 = MapiMessage.FromProperties(sources[i].ObjectData.Properties);if (m1.Attachments.Count > 0) // here the count is always the zero, how can i get the attachment from the embedded msg?GetAttachment(m1.Attachments);}}}
- Get attachment from the pst file.
PersonalStorage pst = PersonalStorage.FromFile(pstpath);FolderInfo folderinfo = pst.RootFolder.GetSubFolder(“Inbox”);int totalcount = folderinfo.ContentCount;int count = (int)Math.Ceiling((double)totalcount / 50);Console.WriteLine(“Count:”+totalcount);MapiMessage msg = null;for (int index = 0, i = 0; i < count; i++){index = i * 50;MessageInfoCollection messageInfoCollection = folderinfo.GetContents(index, 50);// max 50foreach (MessageInfo messageInfo in messageInfoCollection){try{msg = MapiMessage.FromProperties(messageInfo.Properties);//msg = pst.ExtractMessage(messageInfo); it has the workaround. by using ExtractMessageint i = msg.Attachments.Count;msg.Dispose();}catch (Exception ex){throw ex;}}}