none
Clone an appointment/meeting RRS feed

  • Question

  • Hello Techies,

    I am working on a requirement where I need to programmatically clone an appointment/meeting from Outlook calendar. I see that there is a Copy method on AppoinmentItem object that OOM provides. When I used, it does the job; but it basically creates a copy of original item in calendar as soon as I make a call to this method.

    What if I need to make changes to pasted item before saving it to calendar, and let user save it explicitly? Is there any way to handle this situation?

    Additionally, is there any other better way to achieve this cloning than this method?

    Please advise.

    Thanks.


    sureshh...


    • Edited by sureshh Tuesday, January 10, 2017 4:10 PM added additional Q
    Tuesday, January 10, 2017 4:08 PM

Answers

  • No, in OOM the best you can do is copy one property at a time if you do not want the default AppoinmtmentItem.Copy behavior.

    If using Redemption is an option, it exposes RDOAppointmentItem.CopyTo method, which allows to pass either RDOFolder or another RDOAppointmentItem object as the parameter. In the latter case (passing RDOAppointmentItem object), all properties are copied, but the item is not saved - you can modify the target item and call Save when you are done. Keep in mind that at the very least you need to modify the GlobalAppointmentID property.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Tuesday, January 10, 2017 4:20 PM
  • Hello Suresh,

    You need to create a new AppointmentItem from scratch and then set up properties based on the existing item in the calendar.

    The Outlook object model doesn't provide anything special for that.


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    • Proposed as answer by Eugene Astafiev Wednesday, January 11, 2017 7:48 PM
    • Marked as answer by sureshh Wednesday, January 11, 2017 10:22 PM
    Tuesday, January 10, 2017 9:49 PM
  • Doing this one property at a time is better, but still not fool-proof - e.g. it would be very hard to recreate the appointment exceptions with OOM alone.

    What Redemption does in RDOAppointmentItem.CopyTo is copy all the properties on the MAPI level, resulting in a perfect copy with only the entry id and the created/last modified times different. The copy might be a little too perfect since you would need to reset the GlobalAppointmentID property (otherwise Outlook would able to match meeting updated from the Inbox with the existing appointment in the Calendar folder as there would be 2 or more appointments with the same id


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    • Marked as answer by sureshh Wednesday, January 11, 2017 10:22 PM
    Tuesday, January 10, 2017 10:14 PM

All replies

  • No, in OOM the best you can do is copy one property at a time if you do not want the default AppoinmtmentItem.Copy behavior.

    If using Redemption is an option, it exposes RDOAppointmentItem.CopyTo method, which allows to pass either RDOFolder or another RDOAppointmentItem object as the parameter. In the latter case (passing RDOAppointmentItem object), all properties are copied, but the item is not saved - you can modify the target item and call Save when you are done. Keep in mind that at the very least you need to modify the GlobalAppointmentID property.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Tuesday, January 10, 2017 4:20 PM
  • Thanks Dmitry for quick response.

    And do you think the solution provided by Chris in below forum would work if we want to go with copying one property at a time approach instead of AppointmentItem.Copy?

    http://www.outlookcode.com/threads_print.aspx?forumid=5&messageid=29974

    Or you would like to suggest me any other way to copy paste each property at a time?

    Would there be any drawbacks with this approach?

    Also are there any drawbacks / limitations with Redemption approach you suggested?

    Thanks again.


    sureshh...

    Tuesday, January 10, 2017 5:22 PM
  • That solution will not work as it will not copy sub-objects, such as recurrence pattern, recipients, attachments, etc.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Tuesday, January 10, 2017 5:28 PM
  • Hi Dmitry,

    In that case you would like to suggest me any other way to copy paste each property at a time? Would there be any drawbacks with this approach?

    Also are there any drawbacks / limitations with Redemption approach you suggested?

    Thanks again.


    sureshh...

    Tuesday, January 10, 2017 7:45 PM
  • Hello Suresh,

    You need to create a new AppointmentItem from scratch and then set up properties based on the existing item in the calendar.

    The Outlook object model doesn't provide anything special for that.


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    • Proposed as answer by Eugene Astafiev Wednesday, January 11, 2017 7:48 PM
    • Marked as answer by sureshh Wednesday, January 11, 2017 10:22 PM
    Tuesday, January 10, 2017 9:49 PM
  • Doing this one property at a time is better, but still not fool-proof - e.g. it would be very hard to recreate the appointment exceptions with OOM alone.

    What Redemption does in RDOAppointmentItem.CopyTo is copy all the properties on the MAPI level, resulting in a perfect copy with only the entry id and the created/last modified times different. The copy might be a little too perfect since you would need to reset the GlobalAppointmentID property (otherwise Outlook would able to match meeting updated from the Inbox with the existing appointment in the Calendar folder as there would be 2 or more appointments with the same id


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    • Marked as answer by sureshh Wednesday, January 11, 2017 10:22 PM
    Tuesday, January 10, 2017 10:14 PM
  • Thanks Dmitry and Eugene. Got it. I will try this approach further and see if this meets my requirement. Thanks for your inputs. Appreciate it.

    sureshh...


    • Edited by sureshh Wednesday, January 11, 2017 7:14 PM
    Wednesday, January 11, 2017 7:14 PM
  • You are welcome, Suresh!

    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Wednesday, January 11, 2017 7:47 PM