Good Day
I am using the latest version of the imapx dll in order to read the unread message from inbox using the below code:
using(var client = new ImapClient("abc.def.com", 993, true, false))
{
if (client.Connect())
{
if (client.Login("abcd@abc.com", "abc123"))
{
//client.Behavior.ExamineFolders = false;
//client.Behavior.FolderTreeBrowseMode = FolderTreeBrowseMode.Lazy;
//client.Behavior.MessageFetchMode = MessageFetchMode.Tiny;
client.IsDebug = true;
Folder folder = client.Folders.Inbox;
//folder.Examine();
var messages = folder.Search("UNSEEN", MessageFetchMode.Minimal);
foreach (var mess in messages)
{
mess.Seen = true;
Console.WriteLine(mess.Subject);
Console.WriteLine(mess.Body.Text);
Console.WriteLine(mess.From);
}
client.Logout();
client.Disconnect();
}
else
{
throw new Exception("Cannot login to IMAP Server.");
}
}
else
{
throw new Exception("Cannot connect to IMAP Server.");
}
}
when the line:
var disposition = new ContentDisposition(type);
executes, i get the exception: 'An invalid character was found in the mail header: ','."'
also get the format error exception when there is embedded image inside the message body.
Kindly check the same and revert in case i am doing anything wrong here. Since i am using this library for the first time please dont mind if there is a silly mistake.
Thanks in advance,
Durga Charan
Comments: ** Comment from web user: Nexusger **
Hello, I do have the same issue:
__Which Version:__
2.0.0.16
__When does it occur:__
When I try do execute _selectedFolder.Search() in the ImapX.Sample I do get the same error for a specific email.
__Severity:__
High: I can't download any message (and therefore not populate the _selectedFolder) because of the thrown exception.
__Workaround possible:__
Barely: I do have to manually (WebFrontend) delete that mail or move it from the folder.
__Hint for debugging:__
I tracked the error down and found the specific problem: The particular mail has an long and nested BodyStructure-Field (probably embedded mail?). In this BodyStructure there is a field with the following content: "tue, 26 may 2015 14:14:11 +0200" (that is the content of the variable _type_ in the File _BodyStructureParser.cs_ in the method _ReadDisposition()_ on line 412). Here the exception charanmsc08 reported gets thrown.
Because the exception bubbles up, the whole _selectedFolder.Search() breaks. Hence no mails.
__Resources__
See Attachement -> Bodystructure which breaks ImapX