Search The ForumSearch   RegisterRegister  LoginLogin

MailBee.NET IMAP

 AfterLogic Forum : MailBee.NET IMAP
Subject Topic: Get Attachment From Envelope Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
zedekiah
Groupie
Groupie


Joined: 24 June 2009
Location: United States
Online Status: Offline
Posts: 44
Posted: 30 June 2009 at 10:38am | IP Logged Quote zedekiah

How do I get the attachment from the envelope?
Or do I have to go back to the mailserver to get the attachment?

MailBee.Mime.MailMessage msg = imp.DownloadEntireMessage(env.Uid, true);

Is that the only way to get the attachment?
Back to Top View zedekiah's Profile Search for other posts by zedekiah
 
Andrew
AfterLogic Support
AfterLogic Support


Joined: 28 April 2006
Location: United States
Online Status: Offline
Posts: 1189
Posted: 01 July 2009 at 12:48am | IP Logged Quote Andrew

There are two ways:

- use Envelope.GetEnvelopeItem method;
- download envelope with EnvelopeParts.MessagePreview and bodyPreviewSize = -1.

The first way is a bit complex, but downloads only attachment, the second is simpler, but downloads entire message within envelope.


Best regards,
Andrew
Back to Top View Andrew's Profile Search for other posts by Andrew
 
zedekiah
Groupie
Groupie


Joined: 24 June 2009
Location: United States
Online Status: Offline
Posts: 44
Posted: 02 July 2009 at 5:54am | IP Logged Quote zedekiah

The only way I see in the second example is by doing
env.MessagePreview.Attachments.SaveAll(@"C:\Temp");

but I need something that will return bytes[]
like the MailBee.Mime.Attachment.GetData() method.


Back to Top View zedekiah's Profile Search for other posts by zedekiah
 
Andrew
AfterLogic Support
AfterLogic Support


Joined: 28 April 2006
Location: United States
Online Status: Offline
Posts: 1189
Posted: 02 July 2009 at 6:32am | IP Logged Quote Andrew

Try the following:

Code:
byte[] data = env.MessagePreview.Attachments[0].GetData();


Assuming at least one attachment exists.

Or the following loop:

Code:
foreach(Attachment att in env.MessagePreview.Attachments)
{
   byte[] data = att.GetData();
}


Best regards,
Andrew
Back to Top View Andrew's Profile Search for other posts by Andrew
 

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