使用gmail发送电子邮件时未指定smtp主机?
问题描述:
大家好,
我正在尝试使用gmail发送电子邮件.我正在指定主机和所有东西,但这给了我这个错误:未指定smtp主机.
这是我的代码:
Hi all ,
I am trying to send email using gmail.I am specifying the host and every thing but it is giving me this error : The smtp host is not specified.
Here is my code :
Dim smtp As New SmtpClient("smtp.gmail.com", 587)
smtp.DeliveryMethod = SmtpDeliveryMethod.Network
smtp.EnableSsl = True
smtp.UseDefaultCredentials = False
Dim SMTPUserInfo As New System.Net.NetworkCredential("myemail", "pass")
smtp.Credentials = SMTPUserInfo
e.Message.From = New MailAddress("myemail@gmail.com")
e.Message.IsBodyHtml = True
e.Message.Subject = "Allo Magazine : Registration Confirmation Email"
e.Message.Body = e.Message.Body.Replace("<%AC%>", userId.ToString())
smtp.Send(e.Message)
所以请任何人告诉我这是什么错误?
提前谢谢.
So please can anyone tell me what is the error ?
Thanks in advance.
<maildefinition priority="High" from="ahmad.hjaj@gmail.com" bodyfilename="~/ConfirmationEmailHTML/ConfirmationEmail.htm">
</maildefinition>
答
首先想到的是您尚未指定消息的收件人"地址.
除此之外看起来还可以.
The first thing that springs to mind is you haven''t specified the To address for the message.
Other than that it looks ok.