简体   繁体   English

无法发送邮件(VB.net)

[英]Unable to Send Mail (VB.net)

I am trying to send a mail using Dart Control. 我正在尝试使用Dart Control发送邮件。 It was working well with a particular server, but since I switched to a secured server, I receive the following error message: 它在特定服务器上运行良好,但是由于我切换到安全服务器,因此收到以下错误消息:

Protocol Exception-- Request: AUTH LOGIN Response: 530 Must issue a STARTTLS command first 协议异常-请求:AUTH LOGIN响应:530必须首先发出STARTTLS命令

Below is the code : 下面是代码:

Dim Smtp1 As Smtp = New Smtp
Dim SMTPResult As SmtpResult
Dim Message As Dart.Mail.MailMessage = New Dart.Mail.MailMessage()

Smtp1.Session.RemoteEndPoint.Port = intPortNo
strErrLoc = "SMTP1.DnsServerTimeout"
Smtp1.DnsServerTimeout = 15 'default time out 30 seconds

strErrLoc = "Set User Name"
Smtp1.Session.Username = strUserID
Smtp1.Session.Password = strPWD

strErrLoc = "Subject and Mail TEXT"
Message.Subject = strSubject
If strHTMLEmail.Trim = "" Then
    Message.Text = strMailText
Else
    Message.Html = strHTMLEmail
End If

Smtp1.Session.Authentication = Authentication.Auto

Smtp1.Session.RemoteEndPoint.HostNameOrAddress = strServerName.Trim
Smtp1.Session.ServicePrincipleName = "SMTP/" & strServerName.Trim


SMTPResult = Smtp1.Send(Message)

try with enabling SSL mode,like 尝试启用SSL模式,例如

 Smtp1.EnableSSL = True

this works in case of Gmail ,Please Check with yours. 如果使用Gmail,则可以使用此功能,请与您联系。

The suggestion is to use Explicit security. 建议使用显式安全性。

The following Code implementing Explicit Security resolved the issue. 以下实现显式安全性的代码解决了该问题。

Smtp1.Session.Security.Encrypt = Encrypt.Explicit Smtp1.Session.Security.Encrypt =加密。显式

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

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