Author |
|
meyerovb Newbie
Joined: 12 September 2008
Online Status: Offline Posts: 10
|
Posted: 05 May 2009 at 12:03pm | IP Logged
|
|
|
I need to retrieve an attachment from a MailMessage using only it's mime body part identifier. For example, 2 if it is the first attachment, or 3.4 if it is the third attachment of an embedded message, which itself is the second attachment of the original message. It could be the first attachment with a body part specifier of 5, the first 4 parts being text mime parts. Is what I'm trying to do possible?
|
Back to Top |
|
|
meyerovb Newbie
Joined: 12 September 2008
Online Status: Offline Posts: 10
|
Posted: 05 May 2009 at 2:25pm | IP Logged
|
|
|
Nevermind, figured it out:
using (MailMessage message = mb.imap.DownloadEntireMessage(mailFile.UID, true))
{
string[] parts = mailFile.MessagePart.Split(".".ToCharArray());
MimePart mimepart = message.MimePartTree;
foreach (string part in parts)
mimepart = mimepart.SubParts[int.Parse(part) - 1];
using (MemoryStream stream = new MemoryStream(new Attachment(mimepart).GetData()))
zip.AddFileStream(mailFile.FileName, "", stream);
}
|
Back to Top |
|
|