I'm using Microsoft.Exchange.WebServices.Data.ExchangeService
to find a particular email and Reply All to it. I know using System.Net.Mail's MailMessage
, I'm able to set the Priority
property. I'm not seeing the equivalent of this using ExchangeService
?
var exchangeService = new ExchangeService(ExchangeVersion.Exchange2013_SP1);
exchangeService.Credentials = new WebCredentials("usr", "pw", "myDomain.com");
exchangeService.TraceEnabled = false;
exchangeService.AutodiscoverUrl($"{usr}@myDomain.com", AutodiscoverRedirectionUrlValidationCallback);
It finds an email:
var filter = new SearchFilterCollection(LogicalOperator.And, new IsEqualTo(EmailMessageSchema.IsRead, false));
var results = exchangeService.FindItems(WellKnownFolderName.Inbox, filter, new ItemView(50));
var interesting = results.Items.FirstOrDefault(e => e.Subject == "interesting");
It creates a Reply All email:
var response = interesting.CreateReply(true);
response.Body = "I'm important!";
response.Priority = MailPriority.High; // No such property?
response.SendAndSaveCopy();
Before doing var response = interesting.CreateReply(true);
Set the importance of the interesting variable like so
interesting.Importance = Importance.Low;
NOTE: If var interesting
is not an EmailMessage
cast it first. It might be of type Item
When you call CreateReply()
the importance will carry over into the reply.
I tested this like so
var interesting = results.Items.FirstOrDefault();
var orignal = (EmailMessage)interesting;
orignal.Importance = Importance.Low; orignal.CreateReply(true);
orignal.Subject = "Low priority";
orignal.ToRecipients.Add("[email protected]");
orignal.SendAndSaveCopy();
The original email was a high priority and the response was a low priority