My company is using an outdated version of Business Central (On-Prem) - Spring '19 Release, and there are currently no upgrades in the works for the foreseeable future. My inquiry pertains to the 'From Address' when using the codeunit 'Smtp Mail (400)' (yes, I am aware that it has been flagged for elimination), more specifically the first two arguments of the CreateMessage procedure, which are as follows: FromName: Text; FromAddress: Text. and the AddFrom procedure that is subsequently called. While the FromName directive is being followed, the FromAddress directive is not. For testing purposes on my Sandbox, I'm sending from the current user name and address (in this case: ADMIN admin@M365x83076759.OnMicrosoft.com). I'm using my Google Gmail account with an App password in the Smtp Setup. The email headers appear to indicate, upon arrival at the destination, that the initial. From Address had been set: - From ADMIN nwebb767@gmail.com The original message came from ADMIN admin@M365x83076759.OnMicrosoft.com. X-Google-Original-From:
However, it seems that the 'Send mail as' value that is stored in my Gmail settings will eventually be used for the From Address. I attempted to send it as another email address by configuring the settings on my Gmail account (a process that involved 2-step verification). After that, I was unfortunate enough to get an unsatisfactory 'On behalf of' sender hybrid as shown below: -
Nicholas Webb nwebb767@gmail.com; on behalf of; nick@webb-web.co.uk (ADMIN) nick@webb-web.co.uk.
Here's a link that may help you.
https://simplanova.com/blog/how-to-create-and-send-an-email-message-in-business-central-20-using-replaced-smtp-module/