使用gmail发送电子邮件时未指定smtp主机? [英] The smtp host is not specified when sending email using gmail ?
本文介绍了使用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.
这篇关于使用gmail发送电子邮件时未指定smtp主机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文