andyedinborough / aenetmail

C# POP/IMAP Mail Client
370 stars 153 forks source link

Can get body message without Attachments? #99

Open anbinhtrong opened 12 years ago

anbinhtrong commented 12 years ago

I have a mail message with attachment size 25 mb? If I only want to get body message, how can I do it? Gmail just display body html message instead download all message.

anbinhtrong commented 12 years ago

I use the code to get attachments. Size of files is 23,6 mb var dt = DateTime.Now; Console.WriteLine(dt.ToLongTimeString()); // Connect to the IMAP server. The 'true' parameter specifies to use SSL // which is important (for Gmail at least) var ic = new ImapClient("imap.gmail.com", "Your Email", "yourpass", ImapClient.AuthMethods.Login, 993, true); // Select a mailbox. Case-insensitive var mailCount = ic.GetMessageCount(); ic.SelectMailbox("INBOX"); var message = ic.GetMessage(mailCount - 1); var body = message.GetBody(); Console.WriteLine(body); var attachments = message.Attachments; foreach (var attachment in attachments) { Console.WriteLine(string.Format("{0}",attachment.Filename)); attachment.Save(Path.Combine(@"D:\", attachment.Filename)); } ic.Disconnect(); ic.Dispose(); It takes 478,6333763s. It's very slow if I want to see body, not attachments