0
votes

We are trying to create event using EWS which is a part of the migration code. There is a well know issue where we cant set the organizer of event which is the orginal one, here is scenario;

  1. User A is being migrated to User B
  2. User A has 30 events in Calendar
  3. Out of those 30, it has 20 invited events where A is attendee and 10 events which is created by user A (i.e. user A is organizer)
  4. When we migrate them over, using below code all the events are created with User A as organizer. Which is the real issue

    Appointment appointment = new Appointment(exchangeSevice);

    appointment.MimeContent = new MimeContent("UTF-8", System.IO.File.ReadAllBytes(@"c:\A\test.mime"));
    //appointment.MimeContent = ; 
    // Set the properties on the appointment object to create the appointment.
    appointment.Subject = "Tennis lesson with invite 22222";
    appointment.Body = "Focus on backhand this week.";
    appointment.Start = DateTime.Now.AddDays(2);
    appointment.End = appointment.Start.AddHours(1);
    appointment.Location = "Tennis club";
    appointment.ReminderDueBy = DateTime.Now;
    
    Attendee attendee = new Attendee("[email protected]");
    appointment.RequiredAttendees.Add(attendee);
    
    Mailbox mailbox = new Mailbox();
    mailbox.Address = "[email protected]";
    
    // Save the appointment to your calendar.
    appointment.Save(new FolderId(WellKnownFolderName.Calendar, mailbox), SendInvitationsMode.SendToAllAndSaveCopy);
    
    // Verify that the appointment was created by using the appointment's item ID.
    Item item = Item.Bind(exchangeSevice, appointment.Id, new PropertySet(ItemSchema.Subject));
    

Issue is explained here by Microsoft;

https://blogs.msdn.microsoft.com/webdav_101/2011/09/28/howto-set-the-organizer-of-a-meeting-on-the-calendar-of-an-attendee-using-ews/

I am not sure what exactly this paragraph is trying to say;

If you decide to create the meeting using MIME, have the MIME/VCALENDAR content use METHOD:PUBLISH instead of REQUEST. The problem with this is that there are other properties which need to be set. There is no documentation or recommendations on what all would need to be set or if methodology might work in all cases. Further, you might get it to work reliably for now, however it may not work as expected in future updates to Exchange.

Can anyone help on how do I achieve my requirement of create event with different organizer? Is there any chance I can do so?

2

2 Answers

0
votes

What you are doing is not migrating the appointments, but creating new ones.

The property "organizer" is read-only and can't be changed, so you will not succeed this way.

What I'd try is to get the organizers of the appointments from User A, impersonate those (or using delegate access) and send an invitation to User B.

Hot to impersonate another user: https://msdn.microsoft.com/en-us/library/office/dd633680(v=exchg.80).aspx

Hot to get delegate access: https://msdn.microsoft.com/en-us/library/office/dn641957(v=exchg.150).aspx

0
votes

Which is what exactly I was thinking. But in that case, the only fear customer has expressed is that the invitation will boom in their inbox. So assume today is 20th Jan 2017 and there is an event of 15th Jan 2015 which is BACK DATED one. In that case I just cant send invite.

ALso, the other issue is its not necessary that ONLY internal employees are invited. There could be external ones as well who will start getting invite mails. If you see what I mean. So this solution cant work.

What I was hoping was if there is any way I can create programmatically MeetingRequest which TOO isnt possible but if I could create a MIME of MeetingRequest item and save that in inbox. Because what I noticed that if I get event invite, thats being shown in calendar. Obviously that way we cant copy the status whether the user accpeted that or not but atleast this can be a solution. Any suggestion?