Sagar Joshi
Sagar Joshi

Reputation: 582

Automatically creating entry in Outlook calendar using the Exchange API

I am using the Exchange API to send appointment requests from any email address. Below is my code:

ExchangeService exService = new ExchangeService(ExchangeVersion.Exchange2013);
exService.Url = new Uri("exchange URL");
exService.Credentials = new WebCredentials("userID", "password");

Appointment appointment = new Appointment(exService);

appointment.Subject = "Test Subject";
appointment.Body = "test body";
appointment.Location = "Location";
appointment.Start = <Meeting start time>;
appointment.End = <Meeting end time>
appointment.RequiredAttendees.Add("[email protected]");

appointment.Save(SendInvitationsMode.SendOnlyToAll);

This code is working fine: it sends an invitation email to the attendee.

What I want to know is, is it possible to make an entry into the attendee's Outlook calendar directly, without any invitation email or any approval from the attendee?

Upvotes: 1

Views: 4100

Answers (2)

Glen Scales
Glen Scales

Reputation: 22032

No, but if you impersonate the Attendee you can then accept the invitation on their behalf. See:

Upvotes: 1

Prateek Hegde
Prateek Hegde

Reputation: 1

Below code might help you.

ExchangeService exService = new ExchangeService(ExchangeVersion.Exchange2013);
exService.Url = new Uri("exchange URL");
exService.Credentials = new WebCredentials("userID", "password");

Collection<Appointment> Meetings = new Collection<Appointment>();

Appointment appointment = new Appointment(exService);

appointment.Subject = "Test Subject";
appointment.Body = "test body";
appointment.Location = "Location";
appointment.Start = <Meeting start time>;
appointment.End = <Meeting end time>
appointment.RequiredAttendees.Add("[email protected]");
Meetings.add(appointment)

ServiceResponseCollection<ServiceResponse> responses = service.CreateItems(Meetings,WellKnownFolderName.Calendar,MessageDisposition.SendOnly,SendInvitationsMode.SendToNone);

Upvotes: 0

Related Questions