Asynchronously fetches the message summaries for the specified message UIDs.
MailKit (in MailKit.dll) Version: 4.12.1
Syntax Exceptions RemarksFetches the message summaries for the specified message UIDs.
It should be noted that if another client has modified any message in the folder, the IMAP server may choose to return information that was not explicitly requested. It is therefore important to be prepared to handle both additional fields on a IMessageSummary for messages that were requested as well as summaries for messages that were not requested at all.
Examplepublic static void DownloadBodyAndAttachments (string baseDirectory) { using (var client = new ImapClient ()) { client.Connect ("imap.gmail.com", 993, SecureSocketOptions.SslOnConnect); client.Authenticate ("username", "password"); client.Inbox.Open (FolderAccess.ReadOnly); var query = SearchQuery.SubjectContains ("MimeKit").Or (SearchQuery.SubjectContains ("MailKit")); var uids = client.Inbox.Search (query); var items = client.Inbox.Fetch (uids, MessageSummaryItems.UniqueId | MessageSummaryItems.BodyStructure); foreach (var item in items) { var directory = Path.Combine (baseDirectory, item.UniqueId.ToString ()); Directory.CreateDirectory (directory); var bodyPart = item.TextBody; if (bodyPart != null) { var plain = (TextPart) client.Inbox.GetBodyPart (item.UniqueId, bodyPart); var text = plain.Text; File.WriteAllText (Path.Combine (directory, "body.txt"), text); } bodyPart = item.HtmlBody; if (bodyPart != null) { var html = (TextPart) client.Inbox.GetBodyPart (item.UniqueId, bodyPart); var text = html.Text; File.WriteAllText (Path.Combine (directory, "body.html"), text); } foreach (var attachment in item.Attachments) { var entity = client.Inbox.GetBodyPart (item.UniqueId, attachment); if (entity is MessagePart) { var rfc822 = (MessagePart) entity; var path = Path.Combine (directory, attachment.PartSpecifier + ".eml"); rfc822.Message.WriteTo (path); } else { var part = (MimePart) entity; var fileName = attachment.FileName; if (string.IsNullOrEmpty (fileName)) { if (!MimeTypes.TryGetExtension (attachment.ContentType.MimeType, out string extension)) extension = ".dat"; fileName = Guid.NewGuid ().ToString () + extension; } var path = Path.Combine (directory, fileName); using (var stream = File.Create (path)) part.Content.DecodeTo (stream); } } } client.Disconnect (true); } }See Also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4