vb.net 发送电子邮件方法 无需改动 直接Ctrl C V

 Public Function Emilsend(ByVal arrp As Array) As Boolean

        Dim tConsultname As String = G_objService.SB_MyTrim(arrp(0))
        Dim tConsultTel As String = G_objService.SB_MyTrim(arrp(1))

        Dim tConsultNote As String = G_objService.SB_MyTrim(arrp(2))
        Dim ttyperr As String = G_objService.SB_MyTrim(arrp(3))
        Dim tcompany As String = G_objService.SB_MyTrim(arrp(4))

        Dim temail As String = G_objService.SB_MyTrim(arrp(5))
        Try

            Dim Strname1 As String
            If ttyperr = "0" Then
                Strname1 += "食品abcdefg"
            Else
                Strname1 += "化妆品abcdefg"
            End If


            'Dim StrEMail As String = "abcdefg@abcdefg.com;abcdefg@abcdefg.com"


            Dim strFile As String = " Michael:" & vbCr & vbLf
            strFile = strFile & vbCr & vbLf
            strFile = strFile & tConsultNote & vbCr & vbLf
        
            strFile = strFile & " Contactor:" & tConsultname & vbCr & vbLf
            strFile = strFile & " Tel:" & tConsultTel & vbCr & vbLf
            ' Dim strFileOut As String = GetInfoOut(G_objService)
            '  Dim strFileInventory As String = GetInfoInventory(G_objService)
            G_objService.Sys_WriteDebug("strFile", strFile)
            'G_objService.Sys_WriteDebug("strFileOut", strFileOut)
            'G_objService.Sys_WriteDebug("strFileInventory", strFileInventory)


            sendMail("smtp.abcdefg.net", "abcdefg@tatiumsoft.com", "abcdefg", "", "abcdefg@tatiumsoft.com", "abcdefg@qq.com", Strname1, strFile)


            'SendProjectEmailNew(G_objService, StrEMail, "" & Now.Date & "出入库货物查询日报表", strFile, strFileOut, strFileInventory)
            'G_objService.Sys_EMailSendMail("smtp.abcdefg.com", "abcdefg@utclogistics.com.cn", "whsafe01", "abcdefg@utclogistics.com.cn", StrEMail, "", "", Now.Date & "安全库存日报表", "", "", "GB2312", strFile)



            G_objService = Nothing
            Return True
        Catch ex As Exception
            G_objService.Sys_WriteDebug("conTaskKey", "---" & ex.Message)
            Return False
        End Try
    End Function
    Public Sub sendMail(ByVal smtpserver As String, ByVal userName As String, ByVal pwd As String, ByVal nickName As String, ByVal strfrom As String, ByVal strto As String, ByVal subj As String, ByVal bodys As String, Optional ByVal isSSL As Boolean = True)
        Try
            Dim _smtpClient As New SmtpClient()
            _smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network
            _smtpClient.EnableSsl = True
            _smtpClient.Host = smtpserver
            _smtpClient.Port = 465
            _smtpClient.UseDefaultCredentials = True
            ' 使用SMTP用户名和密码进行验证                
            _smtpClient.Credentials = New System.Net.NetworkCredential(userName, pwd) '用户名和密码

            Dim _from As New MailAddress(strfrom, nickName)
            Dim _to As New MailAddress(strto)
            Dim _mailMessage As New MailMessage(_from, _to)
            _mailMessage.Subject = subj '主题
            _mailMessage.SubjectEncoding = System.Text.Encoding.UTF8
            _mailMessage.Body = bodys '内容
            _mailMessage.BodyEncoding = System.Text.Encoding.UTF8 '正文编码
            _mailMessage.IsBodyHtml = False '设置为HTML格式
            _mailMessage.Priority = MailPriority.Normal '优先级

            _smtpClient.Send(_mailMessage)


        Catch ex As Exception
            G_objService.Sys_WriteDebug("sendMail", ex.Message)
        End Try
    End Sub

 

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值