Search The ForumSearch   RegisterRegister  LoginLogin

MailBee.NET IMAP

 AfterLogic Forum : MailBee.NET IMAP
Subject Topic: Retrieve the attachment from its mimepart Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
meyerovb
Newbie
Newbie


Joined: 12 September 2008
Online Status: Offline
Posts: 10
Posted: 05 May 2009 at 12:03pm | IP Logged Quote meyerovb

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 View meyerovb's Profile Search for other posts by meyerovb
 
meyerovb
Newbie
Newbie


Joined: 12 September 2008
Online Status: Offline
Posts: 10
Posted: 05 May 2009 at 2:25pm | IP Logged Quote meyerovb

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 View meyerovb's Profile Search for other posts by meyerovb
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide