'How to withdraw a scheduled email sent with microsoft graph api?

I use the below code. Now I would like to withdraw the email. How?

I tried to set the Id and then delete it. But it says "malformated Id". Also, I´m not sure if this would stop the mail.

var message = new Message
{
    Subject = "Meet for lunch later withID?",
    InternetMessageId = "88dc8516-103a-7df2-2685-1ce9045941b5",
    Body = new ItemBody
    {
        ContentType = BodyType.Text,
        Content = "The new cafeteria is open."
    },
    ToRecipients = new List<Recipient>()
                {
                    new Recipient
                    {
                        EmailAddress = new EmailAddress
                        {
                            Address = "[email protected]"
                        }
                    }
                }
                ,
    SingleValueExtendedProperties = 
        new MessageSingleValueExtendedPropertiesCollectionPage()
        {
            new SingleValueLegacyExtendedProperty
            {
                Id = "SystemTime 0x3FEF",
                Value = DateTime.UtcNow.AddMinutes(5).ToString("o")
            }
        }
};

var saveToSentItems = false;

await graphClient.Me
    .SendMail(message, saveToSentItems)
    .Request()
    .PostAsync();


Solution 1:[1]

Instead of sending the email with a schedule you need to create a draft with a schedule.

 var email =  await graphClient.Me.Messages
                .Request()
                .AddAsync(message);

 await graphClient.Me.Messages[email.Id]
        .Send()
        .Request()
        .PostAsync();

Now this returns the message object with the id. This id can now be used to delete the scheduled email.

   await graphClient.Me.Messages[email.Id]
            .Request()
            .DeleteAsync();

Solution 2:[2]

Drupal community has written a guide about the best method to migrate data and code form Drupal 7 to Drupal 9 :

https://www.drupal.org/docs/drupal-apis/migrate-api/writing-migrations-for-contributed-and-custom-modules

You can consider that everything that has been written about Drupal 8 is valid for Drupal, especially when the purposed code is using the new Symfony API.

When you rewrite your updated module, you have just to tel that it is complatible with Drupal 8 and Drupal 9 into module.info.yml file. The file will lokk like this and the last line concerns Drupal 8 and 9 compatibility :

name: Module name
type: module
description: Module description
package: Custom modules group name
core: 8.x
core_version_requirement: ^8 || ^9

The last important thing is that the module updated version will have to be ready before starting migration because the data migration classes will be included in it.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Benjamin79
Solution 2 Simon Janvier