vb.net发送电子邮件 [英] vb.net send email

查看:176
本文介绍了vb.net发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I was wondering how I could send an email from within a vb application? Can any one assist in where to begin?

推荐答案

使用 System.Net.Mail命名空间中的SmtpClient类

示例。

'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

这篇关于vb.net发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆