Comments on: Moving on from Send-MailMessage: Sending Email from PowerShell using the Graph API https://practical365.com/upgrade-powershell-scripts-sendmailmessage/ Practical Office 365 News, Tips, and Tutorials Fri, 21 Jul 2023 11:55:10 +0000 hourly 1 https://wordpress.org/?v=6.3.2 By: Joost https://practical365.com/upgrade-powershell-scripts-sendmailmessage/#comment-269407 Fri, 21 Jul 2023 11:55:10 +0000 https://practical365.com/?p=52220#comment-269407 I find it strange that there’s a deprecation warning for the entire cmdlet when one use case (authenticated sending via Exchange Online) might stop working.
Unauthenticated send (because your IP address is on a relay whitelist, or because you connect to a foreign mail server where you can’t authenticate anyway) should not result in a deprecation warning, IMO.

]]>
By: Tony Redmond https://practical365.com/upgrade-powershell-scripts-sendmailmessage/#comment-267351 Mon, 26 Jun 2023 19:20:29 +0000 https://practical365.com/?p=52220#comment-267351 In reply to Aaron.

Well, it’s a matter of authentication, so the app needs to reference a certificate that’s known to Azure AD. See https://learn.microsoft.com/en-us/azure/active-directory/develop/howto-create-self-signed-certificate.

BTW, there are other ways to send email using the Graph. See this later article: https://practical365.com/send-email-powershell-graph/

]]>
By: Aaron https://practical365.com/upgrade-powershell-scripts-sendmailmessage/#comment-267349 Mon, 26 Jun 2023 19:14:16 +0000 https://practical365.com/?p=52220#comment-267349 Hi Tony, I found this page a while back and have been using your code in many of my scripts. I’m looking to migrate to certificate-based authentication for these scripts and I was wondering if you had a version showing how to use a certificate instead of the client secret?

]]>
By: Tony Redmond https://practical365.com/upgrade-powershell-scripts-sendmailmessage/#comment-257368 Fri, 24 Mar 2023 16:58:09 +0000 https://practical365.com/?p=52220#comment-257368 In reply to Chris P.

AFAIK, the Graph API methods for sending email all depend on having credentials for a specific mailbox connected to a specific account. Work is ongoing to migrate EWS to the Graph and that’s when support for scenarios like sending email from a shared mailbox using SendAs permission will be supported. At least, that’s what I heard. Don’t quote me on it.

]]>
By: Chris P https://practical365.com/upgrade-powershell-scripts-sendmailmessage/#comment-257358 Fri, 24 Mar 2023 14:58:35 +0000 https://practical365.com/?p=52220#comment-257358 Hi – Do you have an example of acquiring the token with MSAL.PS for the delegated flow?

I have the shared mailbox where a service account has send-as permissions in Exchange Online.
I have the AAD app which has Mail.Send Delegated API permissions.

When I try to access token with MSAL.PS module, the option for client credentials is not there after I specify clientsecret etc.

]]>
By: Mahesh S https://practical365.com/upgrade-powershell-scripts-sendmailmessage/#comment-257098 Wed, 22 Mar 2023 14:01:18 +0000 https://practical365.com/?p=52220#comment-257098 Can we send files or transfer files over smtp to sftp.

]]>
By: Tony Redmond https://practical365.com/upgrade-powershell-scripts-sendmailmessage/#comment-255400 Tue, 28 Feb 2023 18:50:03 +0000 https://practical365.com/?p=52220#comment-255400 In reply to Will.

Nope. I can’t debug code remotely. And advice given without seeing your code is unlikely to be much good.

]]>
By: Will https://practical365.com/upgrade-powershell-scripts-sendmailmessage/#comment-255399 Tue, 28 Feb 2023 18:43:30 +0000 https://practical365.com/?p=52220#comment-255399 Thanks for sharing the script with us.

I tried to use it by replacing the information, but the email was not delivered, nor did it return any errors.
Do you know what it could be?

]]>
By: Tony Redmond https://practical365.com/upgrade-powershell-scripts-sendmailmessage/#comment-253251 Mon, 06 Feb 2023 14:32:25 +0000 https://practical365.com/?p=52220#comment-253251 In reply to Arjan.

I believe that this might be a gap that Microsoft has still to close. The current Graph APIs require a user identifier and don’t appear to support the Send As and Send On Behalf of scenarios for distribution groups and Microsoft 365 groups. I’ve asked Microsoft about this.

]]>
By: Arjan https://practical365.com/upgrade-powershell-scripts-sendmailmessage/#comment-253246 Mon, 06 Feb 2023 12:31:03 +0000 https://practical365.com/?p=52220#comment-253246 Hi,
Just wondering, since this solution cannot be used to send as a Distribution Group, would you know of any Send-MailMessage alternative to do that?
I have a bunch of scripts that send on behalf of a DL, but I cannot find a good way to move this away from Send-MailMessage.
Many thanks!

]]>