Veja o que acabei usando ... Não é o ideal, mas funciona bem.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Exchange.WebServices.Data;
using Microsoft.Exchange.WebServices.Autodiscover;
using System.Net;
namespace program
{
class Program
{
static void Main(string[] args)
{
// Connect to Office 365 Exchange
ExchangeService service = new ExchangeService();
NetworkCredential ncNetworkCredential = new NetworkCredential("user@example", "password", "");
service.Credentials = ncNetworkCredential;
service.AutodiscoverUrl("user@example", delegate { return true; });
// Connect to shared mailbox and get the folder id of the calendar
Mailbox mb = new Mailbox("[email protected]");
FolderId fid = new FolderId(WellKnownFolderName.Calendar, mb);
// Create a string to hold all of the email content...
String emailBody = "";
emailBody += "<p style=\"font-size:10pt; color: #AAA;text-align:center;\">Please do not reply to this email.</p>";
// Create a weekly calendar view...
CalendarView view = new CalendarView(DateTime.Now.AddDays(1).AddHours(-7),DateTime.Now.AddDays(8));
FindItemsResults<Appointment> results = service.FindAppointments(fid, view);
// Look through the appointments of the week.
for (int i = 0; i < results.Items.Count; i++)
{
try
{
// Add text to the email body.
emailBody += "<p>";
emailBody += "Task: " + results.Items[i].Subject.ToString() + "<br />";
emailBody += "Resource: " + results.Items[i].Location.ToString() + "<br />";
emailBody += "Date: " + results.Items[i].Start.ToShortDateString() + " " + results.Items[i].Start.ToShortTimeString() + "<br />";
emailBody += "</p>";
}
catch
{
// Add text to the email body.
emailBody += "<p>";
emailBody += "Task: " + results.Items[i].Subject.ToString() + "<br />";
//emailBody += "Resource: " + results.Items[i].Location.ToString() + "<br />";
emailBody += "Date: " + results.Items[i].Start.ToShortDateString() + " " + results.Items[i].Start.ToShortTimeString() + "<br />";
emailBody += "</p>";
}
}
// Line referencing the calendar.
emailBody += "<p style=\"color: red;text-align:center;\">For more information on tasks check the \"calendar\"</p>";
// Create a new email message.
EmailMessage email = new EmailMessage(service);
email.ToRecipients.Add("[email protected]");
email.Subject = "Scheduled Tasks (" + DateTime.Now.ToShortDateString() + ")";
email.Body = emailBody;
try
{
email.Send();
}
catch (Exception e)
{
Console.WriteLine("Error: " + e);
}
}
}
}