I am trying to use EWS to schedule an appointment then cancel it using EWS.I have 2 domains configured on my exchange server old_domain.com and new_domain.com.
username@old_domain.com is the fully qualified username and it is the one I must log in with to be authorized. The new_domain.com is set as an alias and is used as the default for everything. For example, when I send an email, by default it comes out of username@new_domain.com not username@old_domain.com
I was able to created the appointment with no issue. However, the Organizer is showing at username@new_domain.com not the fully quantified domain username@old_domain.com. So when I cancel the appointment, I get the following error
User must be an organizer for CancelCalendarItem action.
Here is my code.
// create the service
WebCredentials credentials = new WebCredentials("username", "password", "old_domain.com");
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013)
{
Credentials = credentials,
Url = new Uri("https://webmail.old_domain.com/ews/exchange.asmx"),
};
// create the appointment
Appointment appointment = new Appointment(service)
{
Subject = "Test",
Start = DateTime.Now,
StartTimeZone = TimeZoneInfo.Local,
ReminderMinutesBeforeStart = 60,
};
appointment.End = appointment.Start.AddMinutes(60);
appointment.EndTimeZone = appointment.StartTimeZone;
appointment.Resources.Add("room1@old_domain.com");
appointment.Save(SendInvitationsMode.SendOnlyToAll);
// cancel the meeting
appointment.CancelMeeting();
How can I correctly cancel my appointment using EWS?
I was able to created it by setting the organizer address after the appointment was created