Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception occur when fetching with the "PreviewText" item #881

Closed
moyanming opened this issue Jul 21, 2019 · 1 comment
Closed

Exception occur when fetching with the "PreviewText" item #881

moyanming opened this issue Jul 21, 2019 · 1 comment
Labels
bug Something isn't working

Comments

@moyanming
Copy link

moyanming commented Jul 21, 2019

Hi,
If the "| MessageSummaryItems.PreviewText" add to the fetch, there may be exception occur. It seems that when the preview text is null and the MimeUtils.TryParse() can't deal with this situation.

if ((client.Capabilities & (ImapCapabilities.SpecialUse | ImapCapabilities.XList)) != 0)
{
    var folder = client.GetFolder(SpecialFolder.Sent);
    folder.Open(FolderAccess.ReadOnly);
    var sums = folder.Fetch(0, -1, MessageSummaryItems.All
        | MessageSummaryItems.BodyStructure
        | MessageSummaryItems.PreviewText);
}
{"Value cannot be null.\r\nParameter name: text"}
at MimeKit.Utils.MimeUtils.TryParse(String text, ContentEncoding& encoding)\r\n   
at MailKit.Net.Imap.ImapFolder.FetchPreviewTextContext.Add(Section section)\r\n   
at MailKit.Net.Imap.ImapFolder.FetchStreamAsync(ImapEngine engine, ImapCommand ic, Int32 index, Boolean doAsync)\r\n   
at MailKit.Net.Imap.ImapEngine.ProcessUntaggedResponseAsync(Boolean doAsync, CancellationToken cancellationToken)\r\n   
at MailKit.Net.Imap.ImapCommand.StepAsync(Boolean doAsync)\r\n   
at MailKit.Net.Imap.ImapEngine.IterateAsync(Boolean doAsync)\r\n   
at MailKit.Net.Imap.ImapEngine.RunAsync(ImapCommand ic, Boolean doAsync)\r\n   
at MailKit.Net.Imap.ImapFolder.GetPreviewTextAsync(FetchSummaryContext sctx, Boolean doAsync, CancellationToken cancellationToken)\r\n   
at MailKit.Net.Imap.ImapFolder.FetchAsync(Int32 min, Int32 max, MessageSummaryItems items, Boolean doAsync, CancellationToken cancellationToken)\r\n   
at MailKit.Net.Imap.ImapFolder.Fetch(Int32 min, Int32 max, MessageSummaryItems items, CancellationToken cancellationToken)\r\n 
@moyanming moyanming changed the title Exception occur when fetching with the null value of the "PreviewText" item Exception occur when fetching with the "PreviewText" item Jul 21, 2019
jstedfast added a commit that referenced this issue Jul 22, 2019
@jstedfast jstedfast added the bug Something isn't working label Jul 22, 2019
@jstedfast
Copy link
Owner

Thanks for the bug report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants