RequiredAttendees with EWS

I was having trouble figuring out how to get the required attendees copied from Exchange 2007 to Exchange in the cloud.

After much searching I came across this post: http://stackoverflow.com/questions/3731303/exchange-web-services-create-…

While this gave me the bones to get the required attendees on an appointment, I needed to be able to add the attendees dynamically.

Here is what I came up with:

ResourceMailboxes.ExchangeWebServices.ItemInfoResponseMessageType rmResponseMessage = giResponse.ResponseMessages.Items[0] as ResourceMailboxes.ExchangeWebServices.ItemInfoResponseMessageType;

ResourceMailboxes.ExchangeWebServices.CalendarItemType ciCalentry = (ResourceMailboxes.ExchangeWebServices.CalendarItemType)rmResponseMessage.Items.Items[0];
int i = 0;

string strAttendees = string.Empty;

foreach (ResourceMailboxes.ExchangeWebServices.AttendeeType atAttendee in ciCalentry.RequiredAttendees)
{
if (atAttendee.Mailbox.EmailAddress.ToString().Trim() != string.Empty)
{
if (strAttendees == string.Empty)
{
strAttendees = atAttendee.Mailbox.EmailAddress.ToString();
}
else
{
strAttendees += “:” + atAttendee.Mailbox.EmailAddress.ToString();
}
Console.WriteLine(strAttendees);
//arrAttendees[i] = atAttendee.Mailbox.EmailAddress.ToString();
i++;
}
}
string[] arrAttendees = strAttendees.Split(new char[] { ‘:’ });
ResourceMailboxes.LiveEduWebService.AttendeeType[] arrAttendeeType = new ResourceMailboxes.LiveEduWebService.AttendeeType[i];
for (int x = 0; x < i; x++)
{
ResourceMailboxes.LiveEduWebService.AttendeeType attType = new ResourceMailboxes.LiveEduWebService.AttendeeType
{
Mailbox = new ResourceMailboxes.LiveEduWebService.EmailAddressType
{
EmailAddress = arrAttendees[x].ToString(),
RoutingType = “SMTP”
}
};
arrAttendeeType[x] = attType;
}
calendarItem.RequiredAttendees = arrAttendeeType;

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s