通过vb.net应用程序发送邮件 [英] Sending Mail through vb.net application
本文介绍了通过vb.net应用程序发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好.我正在尝试通过vb.net应用程序发送邮件,但出现错误
发送邮件失败."任何人都可以帮助我解决此问题吗?下面是我编写的代码.
提前谢谢..
Hi all.I am trying to send mail through my vb.net application but I am getting error
"Failure sending mail."Can any1 please help me to solve this?Below is the code which I have written.
Thanx in advance..
Private Sub Send_Mail(ByVal SendTo As String, ByVal Subject As String, ByVal Body As String)
Dim strFrom As String = "myemail@gmail.com"
Dim strto As String = SendTo
Dim strSubject As String = Subject
Dim strbody As String = Body
Dim smtp As SmtpClient = New SmtpClient()
Dim msg As MailMessage = New MailMessage(strFrom, strto, strSubject, strbody)
msg.IsBodyHtml = True
smtp.Host = "localhost"
smtp.Send(msg)
MsgBox("Mail Sent.")
End Sub
推荐答案
http://www.java-samples.com/showtutorial.php?tutorialid=1056 [ ^ ]
在VB.net中轻松发送电子邮件 [ ^ ]
http://www.emailarchitect.net/easendmail/kb/vbnet.aspx [ ^ ]
http://vb.net-informations.com/communications/vb.net_smtp_mail.htm [ ^ ]
http://www.java-samples.com/showtutorial.php?tutorialid=1056[^]
Easily Send E-mail in VB.net[^]
http://www.emailarchitect.net/easendmail/kb/vbnet.aspx[^]
http://vb.net-informations.com/communications/vb.net_smtp_mail.htm[^]
可能您需要设置授权-很少有系统会允许您在不知道电子邮件发往哪个帐户的情况下发送电子邮件.
在此处查看:使用C#发送带有或的电子邮件不带附件:通用例程. [ ^ ]-在C#中,但在VB中的调用是相同的
Probably, you need to set the authorization - very, very few systems will let you send email without knowing which account it is going from.
Have a look here: Sending an Email in C# with or without attachments: generic routine.[^] - it''s in C# but the calls are the same in VB
这篇关于通过vb.net应用程序发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文