Office 365 SMTP not working anymore with ASP.NET VB Page

Jeff Thomas 21 Reputation points
2022-11-29T18:41:08.577+00:00

I've attempted several changes that I received from Microsoft and still not successful. Everything worked until around February 2022. I understand that Microsoft made some changes in regards to SMTP authentication. I have the SMTP credentials setup in webconfig as seen below and the code is in VB. I appreciate any help I can receive!

265290-screenshot-2022-11-29-at-113603-am.png

265391-screenshot-2022-11-29-at-113805-am.png

Exchange Online
Exchange Online
A Microsoft email and calendaring hosted service.
6,171 questions
Developer technologies VB
Developer technologies ASP.NET Other
0 comments No comments
{count} votes

Accepted answer
  1. Lan Huang-MSFT 30,186 Reputation points Microsoft External Staff
    2022-11-30T03:04:49.76+00:00

    Hi @Jeff Thomas ,
    I simply tested your code, you need to define username.text, vbCrLf will not report an error, or you can use the Environment.NewLine property instead.

    Message.Body = "First Line" + Environment.NewLine + "second line"  
    

    My code below works fine, you can refer to it.

     <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>  
                <asp:Button ID="Button1" runat="server" Text="Button" />  
    

    265536-image.png

    <system.net>  
    		<mailSettings>  
    			<smtp>  
    				<network host="smtp.office365.com" password="*****" port="587" userName="****" enableSsl="true"/>  
    			</smtp>  
    		</mailSettings>  
    	 <defaultProxy>  
         <proxy usesystemdefault="False"/>  
       </defaultProxy>  
    	</system.net>  
    

    Best regards,
    Lan Huang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


1 additional answer

Sort by: Most helpful
  1. Jeff Thomas 21 Reputation points
    2022-12-02T04:19:34.84+00:00

    Thank you for your response! The thread you referenced had the fix! I need to add the "ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12" and it worked! See screen shot below.

    I can't thank you enough! 266407-screenshot-2022-12-01-at-91606-pm.png

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.