We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Exchange: Fetch attachments only

Hi,

I was checking the FetchAttachment call but unable to do an example. Can you please share some example?

Hi Aaron,

Following is a sample code which fetches an attachment from an unread message in the inbox. In this sample the target message contains multiple attachment and we just want to fetch an arbitrary attachment like “Attachment.docx”. Could you please give it a try and let us know the feedback?

ImapClient client = new ImapClient(“[imap.gmail.com](http://imap.gmail.com/)”, 993, “user_name”, “password”);

client.SecurityOptions = SecurityOptions.SSLImplicit;

client.SelectFolder("Inbox");

ImapQueryBuilder builder = new ImapQueryBuilder();

MailQuery qry = builder.HasNoFlags(ImapMessageFlags.IsRead);

ImapMessageInfoCollection messages = client.ListMessages(qry);

foreach (ImapMessageInfo info in messages)

{

Attachment att = client.FetchAttachment(info.SequenceNumber, "Attachment.docx");

}