【问题标题】:vb.net send emailvb.net 发送电子邮件
【发布时间】:2016-12-18 22:40:02
【问题描述】:

我想知道如何从 vb 应用程序中发送电子邮件?任何人都可以协助从哪里开始?

【问题讨论】:

    标签: vb.net email


    【解决方案1】:

    使用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
    

    【讨论】:

    • 代码将在 Microsoft Exchange 服务器上运行。我需要做一些不同的事情吗?
    • 我不是设置交换服务器的专家,但我有很多应用程序通过上述交换服务器发送邮件。你obv。必须用您的交换服务器名称更改“localhost”。
    【解决方案2】:

    您可以使用System.Net.Mail 命名空间,查看它是否有帮助。我使用 C#,但我想它是相似的,创建一个客户端,然后是一条消息,设置消息的参数,然后 client.Send() 将发送消息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-12-24
      • 2014-01-06
      • 1970-01-01
      • 2015-06-11
      • 2012-01-16
      • 2012-09-20
      • 2016-06-26
      • 1970-01-01
      相关资源
      最近更新 更多