提问人:Slugsie 提问时间:10/10/2023 最后编辑:Slugsie 更新时间:10/10/2023 访问量:99
通过 Outlook365 从 VB6/VB.net 4.0 应用程序发送电子邮件
Sending email via Outlook365 from VB6/VB.net 4.0 application
问:
我们目前有一个遗留的 VB6/VB.Net 4.0 应用程序(不幸的是,由于需要支持 XP,我们坚持使用这些应用程序),它的功能之一是发送电子邮件。它目前可以使用Ostrosoft SMTP组件与我们的各种客户端SMTP服务器一起使用。但是,它不适用于 Office365,因为它现在需要使用带有“StartTLS”的 TLS1.2,而 Ostrosoft 组件不支持。
我在 .Net 中尝试了各种方法,但似乎没有任何效果。
例如:
Try
Using SMTPMailServer As New Net.Mail.SmtpClient()
Using MailMessage As Net.Mail.MailMessage = New Net.Mail.MailMessage()
SMTPMailServer.Port = 587
SMTPMailServer.Host = "smtp.office365.com"
SMTPMailServer.EnableSsl = True
SMTPMailServer.DeliveryMethod = SmtpDeliveryMethod.Network
SMTPMailServer.UseDefaultCredentials = False
SMTPMailServer.Credentials = New Net.NetworkCredential("**id**", "**password**")
MailMessage.From = New MailAddress(FromAddress)
MailMessage.To.Add(ToAddress)
MailMessage.Subject = $"Test Email {DateTime.Now}"
MailMessage.Body = "This is for testing SMTP mail using Method 1"
SMTPMailServer.Send(MailMessage)
End Using
MsgBox("Mail sent")
End Using
Catch ex As Exception
MsgBox($"Error : {ex.Message}")
End Try
这会导致以下错误:
SMTP 服务器需要安全连接,否则客户端未通过身份验证。服务器响应为:5.7.57 客户端未通过身份验证来发送邮件。错误:535 5.7.139 身份验证失败,请求不符合要成功进行身份验证的条件。
有人对此有解决方案吗?谢谢。
请注意,我已尝试将ServicePointManager.SecurityProtocol设置为3072,没有更改。
答: 暂无答案
评论
SMTPMailServer.Host = "192.168.x.y";