简体   繁体   中英

Delete Calendar Event permanently using Microsoft Graph API

I am writing a scheduled service that writes public transport duty data into Exchange-Online calendars of bus drivers by using Microsaft Graph API. Since those duties may be splittet, changed or skipped at any day we have decided to delete previous entries on each process run and write new entries.

All that is working fine except that the deleted item after deletion end up in the deleted item mail folder. Is there any way to avoid that and delete permanentely?

When you delete calendar event then the deleted item mail folder will contain an item of @odata.type #microsoft.graph.eventMessageRequest

Get messages from the deleted item mail folder

var messages = await graphClient.Me.MailFolders["{id_of_deleted_item_mail_folder}"]
    .Messages
    .Request()
    .GetAsync();

// it returns items of Message type
// filter message of EventMessage which derives from Message

Delete the event message by calling

await graphClient.Me.MailFolders["{id_of_deleted_item_mail_folder"]
    .Messages["{event_message_id}"]
    .Request()
    .DeleteAsync();

It will remove the message from deleted item mail folder.

Resources:

Event message

Delete event message

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM