简体   繁体   English

Office 365 SMTP vb.net

[英]office 365 smtp vb.net

I developed a vp.net web app contains a function that sends emails it was running normally until last Monday any suggestions. 我开发了一个vp.net网络应用程序,其中包含一个功能,该功能可以正常运行电子邮件,直到上周一为止。 the following code explain what I am using to use smtp.office365.com:- 以下代码说明了我使用smtp.office365.com的用途:-

 `Dim SendMessage As New MailMessage

    SendMessage.To.Add("ToMail")
    SendMessage.CC.Add("CCMail")
    SendMessage.From = New MailAddress("MyMail")
    SendMessage.Subject = subject

    SendMessage.Body = "Test"

    SendMessage.IsBodyHtml = True

    Try


        Dim client As New SmtpClient("smtp.office365.com", 587)
        SendMessage.Priority = MailPriority.High
        client.EnableSsl = True

        client.UseDefaultCredentials = False
        Dim x As New Net.NetworkCredential("Mail", "Password")
        client.Credentials = x

        client.DeliveryMethod = SmtpDeliveryMethod.Network
        client.SendAsync(SendMessage, Nothing)


    Catch ex As Exception
        MsgBox(ex.ToString())


    End Try`

问题出在防火墙阻止了端口587和25

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM