【发布时间】:2016-12-18 22:40:02
【问题描述】:
我想知道如何从 vb 应用程序中发送电子邮件?任何人都可以协助从哪里开始?
【问题讨论】:
我想知道如何从 vb 应用程序中发送电子邮件?任何人都可以协助从哪里开始?
【问题讨论】:
使用SmtpClient class within the System.Net.Mail namespace
示例。
'create the mail message
Dim mail As New MailMessage()
'set the addresses
mail.From = New MailAddress("xx@xx")
mail.[To].Add("xx@xx")
'set the content
mail.Subject = "This is an email"
mail.Body = "this is a sample body"
'set the server
Dim smtp As New SmtpClient("localhost")
'send the message
Try
smtp.Send(mail)
Response.Write("Your Email has been sent sucessfully - Thank You")
Catch exc As Exception
Response.Write("Send failure: " & exc.ToString())
End Try
【讨论】:
您可以使用System.Net.Mail 命名空间,查看它是否有帮助。我使用 C#,但我想它是相似的,创建一个客户端,然后是一条消息,设置消息的参数,然后 client.Send() 将发送消息。
【讨论】: