| 站点地图 | 联系我
| www.asm32.net | 2006版 | 资料中心 | linux | asm/asm32 | C/C++ | VC++ | java | 书签 | ASP.Net书签 | 上善若水 厚德载物
 现在位置 :: 主页 >> 资料中心 >> ROOT / CODE / B/S / asp.net(vb) /
 

在asp.net里面发送邮件

来源(百度知道)

From: http://zhidao.baidu.com/question/126074645.html

Imports Microsoft.VisualBasic
Imports System.Net.Mail
Imports System.Net.Mime

Public Class LiteMail
    ''' <summary>
    ''' 发送一个文本邮件到指定的电子邮箱。
    ''' </summary>
    ''' <param name="MailTo">收件人电子邮件地址</param>
    ''' <param name="Subject">邮件标题</param>
    ''' <param name="Body">邮件正文</param>
    ''' <remarks></remarks>
    Public Shared Sub SendMail(ByVal MailTo As String, ByVal Subject As String, ByVal Body As String)
        Dim m1 As MailMessage = New MailMessage
        m1.BodyEncoding = System.Text.Encoding.UTF8
        m1.IsBodyHtml = True
        m1.From = New MailAddress("youmail@domain.com") '发件人邮箱
        m1.To.Add(New MailAddress(MailTo))
        Dim c As SmtpClient = New SmtpClient("mail.domain.com") 'smtp服务器地址
        m1.Subject = Subject
        m1.Body = Body
        c.UseDefaultCredentials = False
        c.Credentials = New System.Net.NetworkCredential("youname@domain.com", "password") ’邮箱地址,密码
        c.DeliveryMethod = SmtpDeliveryMethod.Network
        Try
            c.Send(m1)
        Finally
        End Try
    End Sub
End Class

Link: http://www.asm32.net/article_details.aspx?id=5633


浏览次数 0 发布时间 2011/1/8 22:46:29 从属分类 asp.net(vb) 【评论】【 】【打印】【关闭
 
| www.asm32.net | 2006版 | 资料中心 | linux | asm/asm32 | C/C++ | VC++ | java | 书签 | ASP.Net书签 | 京ICP备09029108号-1