It is easy to operate Office365 mail with Microsoft.Exchange.WebServices. Several important attributes are listed here.
Typically, a WebServices object is defined first in the code.
Exchangeservice service = new Exchangeservice ();
(1) service. Timeout = 200000;
The default service operation, Office365, is 100 seconds, but if the program connects to the server for a long time, the connection server time-out occurs frequently, and the timeout attribute allows you to extend the request.
(2) Searchfilter unreadfilter = new Searchfilter.searchfiltercollection (Logicaloperator.and, new Searchfilter.isequalto (Emailmessageschema.isread,false));
With the Serchfilter property, you can customize the type of Get Office365 message, and get unread messages by setting Emailmessageschema.isread to false on the above.
(3) Fetchemail. Load ();
When the message is obtained, the default system does not return the message body subject content (for example, you get 1000 messages at a time, the system only returns core content, such as the message received, the message header, but does not return the message body)
The load () method needs to be called manually
(4) Microsoft.Exchange.WebServices.Data.AttachmentCollection attachments = Fetchemail. Attachments;
WebServices provides a Attachmentcollection object that can get the attachment set for the message.
However, and the message type, the list of attachments returned by the system is just the title of the attachment, so you need to call Fileattachment.load () to get the details of the attachment.
(5) Fetchemail. Isread = true; Fetchemail. Update (Conflictresolutionmode.alwaysoverwrite);
You can update messages with the Update method.
Handling several properties of Office365 messages with Microsoft.Exchange.WebServices