smiley22 / S22.Imap

A free, easy-to-use and well-documented .NET library component for communicating with IMAP servers
http://smiley22.github.com/S22.Imap/Documentation/
MIT License
211 stars 115 forks source link

GetMessages throw System.ArgumentException #150

Closed edika99 closed 5 years ago

edika99 commented 5 years ago

I've tried to use this library to retrieve messages with a windows service in my internal Microsoft Exchange Server. I can access the server and read messages with thunderbird so IMAP service is working correctly. When I try to retrieve messages with S22 I always get an exception on GetMessages The exception is

System.ArgumentException Message: Value cannot be null - parameter name: value

in StackTrace I found this method

in System.Net.Mime.HeaderCollection.Add(String name, String value)

if I hit F10 in Visual studio during debug the the Message of the Exception change

Value cannot be null - Parameter name Key an in the StackTrace now there is

in System.Collections.Generic.Dictionary`2.FindEntry(TKey key)

The code ise very simple and copied from your examples:

IEnumerable<uint> uids = client.Search(SearchCondition.All()); var messages = client.GetMessages(uids,true);

after hitting many times the F10 button the procedure go forward and is able to read messages and attachment. It looks there are messages the missing something and cause the exception when the Method create the MailMessage object.

Edika

edika99 commented 5 years ago

Sorry Just realize that Exception is thrown only in debug .