public static void Run()
{
// ExStart:GetMailTips
// Create instance of EWSClient class by giving credentials
IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain");
Console.WriteLine("Connected to Exchange server...");
// Provide mail tips options
MailAddressCollection addrColl = new MailAddressCollection();
addrColl.Add(new MailAddress("[email protected]", true));
addrColl.Add(new MailAddress("[email protected]", true));
GetMailTipsOptions options = new GetMailTipsOptions("[email protected]", addrColl, MailTipsType.All);
// Get Mail Tips
MailTips[] tips = client.GetMailTips(options);
// Display information about each Mail Tip
foreach (MailTips tip in tips)
{
// Display Out of office message, if present
if (tip.OutOfOffice != null)
{
Console.WriteLine("Out of office: " + tip.OutOfOffice.ReplyBody.Message);
}
// Display the invalid email address in recipient, if present
if (tip.InvalidRecipient == true)
{
Console.WriteLine("The recipient address is invalid: " + tip.RecipientAddress);
}
}
// ExEnd:GetMailTips
}
}