• 邮箱代码


    ''' <summary>
    ''' 邮箱代码
    ''' </summary>
    ''' <param name="toaddress">收件人地址</param>
    ''' <param name="toname">收件人名字</param>
    ''' <param name="caosongren">抄送人</param>
    ''' <param name="mimiren">密件抄送人</param>
    ''' <param name="subject">主题</param>
    ''' <param name="body">正文</param>
    ''' <returns> 不返回</returns>
    ''' <remarks></remarks>
    Public Shared Sub senderemail(ByVal toaddress As String, ByVal toname As String, ByVal caosongren As String, ByVal mimiren As String, ByVal subject As String, ByVal body As String)

    Dim client As SmtpClient = New SmtpClient("smtp.163.com")
    client.Host = "smtp.163.com"
    'client.Port="端口"
    client.UseDefaultCredentials = False
    client.Credentials = New System.Net.NetworkCredential("xxxxx@163.com", "密码")
    client.DeliveryMethod = SmtpDeliveryMethod.Network
    Dim addressfrom As MailAddress = New MailAddress("xxxxx@163.com", "我是test")
    Dim addressto As MailAddress = New MailAddress(toaddress, toname)
    Dim messages As MailMessage = New MailMessage(addressfrom, addressto)
    Dim cc As MailAddress = New MailAddress(caosongren) '抄送人
    messages.CC.Add(cc)
    Dim mim As MailAddress = New MailAddress(mimiren) '密人
    messages.Bcc.Add(mim)
    messages.Priority = MailPriority.High
    messages.Body = body
    messages.Subject = subject
    messages.BodyEncoding = System.Text.Encoding.UTF8
    messages.IsBodyHtml = True

    Try
    client.Send(messages)
    Catch ex As Exception
    Throw ex
    End Try

    End Sub

  • 相关阅读:
    Android连载7-动语添加碎片
    JavaScript连载6-转化为Number和Boolean类型、运算符
    Java连载111-timer定时器、反射机制概述
    用conda创建虚拟环境的一些常用命令
    Java内存分析
    Java语言中的Class类
    线程协作
    LeetCode刷题笔记第26题
    LeetCode刷题笔记第20题(括号匹配)
    LeetCode刷提笔记第1332题
  • 原文地址:https://www.cnblogs.com/annabook/p/3628887.html
Copyright © 2020-2023  润新知