Hi Guys
Hi Brian,
Thank you for using Aspose.Email.
You can use the following code sample that ignores fetching the message attachments. Setting the second flag of FetchMessage to “true” will ignore fetching message attachments. Please let us know if we can be of any additional help to you in this regard.
Sample Code:
ImapClient client = new ImapClient();
client.Host = "exchange.domain.com";
client.Username = "username";
client.Password = "password";
client.SelectFolder("Inbox");
ImapMessageInfoCollection coll = client.ListMessages();
foreach (ImapMessageInfo msgInfo in coll)
{
MailMessage msg = client.FetchMessage(msgInfo.SequenceNumber, true);
Console.WriteLine(msg.Attachments.Count);
msg.Save("a.eml", MailMessageSaveType.EmlFormat);
}
Hi Kashif
Hi Brian,
You can save the regular attachments from the fetched message as shown in the following code sample. Please note that signatures such as company logo etc. embedded in a message’s body are treated as LinkedResources whihc are different than regular attachments. Let us know if we can be of any additional help to you in this regard.
Sample Code:
ImapClient client = GetAsposeImapClient1();
client.SelectFolder("Inbox");
ImapMessageInfoCollection coll = client.ListMessages();
foreach (ImapMessageInfo msgInfo in coll)
{
MailMessage msg = client.FetchMessage(msgInfo.SequenceNumber);
Console.WriteLine(msg.Attachments.Count);
//Save message attachments to disc
foreach (Attachment att in msg.Attachments)
att.Save(att.Name);
}
Hi
Hi Brian,
IEWSClient client = GetAsposeEWSClient();
ExchangeMessageInfoCollection messagesInfo = client.ListMessages(client.MailboxInfo.InboxUri,10, ExchangeListMessagesOptions.FetchAttachmentInformation);
Console.WriteLine(“Imap: " + messagesInfo.Count + " message(s) found.”);
foreach(ExchangeMessageInfo info in messagesInfo)
{
if(info.HasAttachments)
{
ExchangeAttachmentInfoCollection AttchInfoColl = info.Attachments;
foreach (ExchangeAttachmentInfo AttchInfo in AttchInfoColl)
{
Console.WriteLine(AttchInfo.AttachmentUri);
Console.WriteLine(AttchInfo.Name);
Console.WriteLine(AttchInfo.Size);
if(!AttchInfo.Name.Contains(“Some Criteria etc.”))
{
//Download the attachment
Aspose.Email.Mail.Attachment attch = client.FetchAttachment(AttchInfo.AttachmentUri);
}
}
}
}