Azure Web Application programmatically send subscription password via email to Clients (A2P) SMTP relay to Office 365 business email account not working

Carlos 0 Reputation points
2023-03-07T18:48:02.1833333+00:00
"I am trying to programmatically email a password to a new user from my Azure website via the vb.net code in my *.aspx signup page. 
 
Options tried include: 
1) Programmatically send SMTP relay to client via my Office365 Business Basic Email account, OR 
2) trying the new Azure Email Communication Service 
I have had no success with either option to date. 
  
Option 1:  
I have a connector setup on Office 365 Exchange server to accept communications from my azure website with SSL certificate which includes name 'website.com'
The following code worked 3/6/2023 on the website from my *.aspx signup page using PORT 25 but not locally in Visual Studio.  
I tried changing to PORT 587 and it failed.  
After reverting to PORT 25 it no longer worked either with ERROR: 'Mailbox Not available'
I have a connector setup on Office 365 Exchange server to accept communications from mail server with certificate which includes name 'website.com'  "

 Dim SmtpServer As New SmtpClient()
            Dim mail As New MailMessage()
            SmtpServer.EnableSsl = True                                                                                                                                SmtpServer.DeliveryFormat = 1
            SmtpServer.DeliveryFormat = 1                                                                                                                       
            SmtpServer.Port = 25
            SmtpServer.Host = "website-com.mail.protection.outlook.com"
            mail = New MailMessage()
            mail.From = New MailAddress("support@website.com")
            mail.To.Add(client@gmail.com)                                                                                                                               
            mail.Bcc.Add("support@website.com")
            mail.Subject = "Your password for downloading"                                                                                                                              
            mail.SubjectEncoding = System.Text.Encoding.UTF8
            mail.BodyEncoding = System.Text.Encoding.UTF8
            mail.IsBodyHtml = True
            mail.Body = "Testing SMTP mail from Azure To Microsoft Office Basic 365"
            SmtpServer.Send(mail)

I am not fixated on an approach, but I would appreciate a solid long term solution. 
  Thanks !! 
Outlook
Outlook
A family of Microsoft email and calendar products.
2,910 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,573 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,456 questions
{count} votes