Send Mail from Automation Runbook

On my last customer session, I had the following situation, that I can’t send mails from my runbook (Azure Automation) over an Office 365 Mail enabled user.

I always got the following error information

After some investigation (google search) I’ve found the right Microsoft article.

My code looks like:

So my scenario was option1 from the Microsoft article, but I only wanted to send an E-Mail from “” to an internal user “”.

In that case I can use option2 from the Microsoft article.

I’ve changed my code and everything was working fine: