用JMail发送邮件

Function SendMail(ByVal From As String, _
                ByVal Recipient As String, _
                ByVal RecipientCC As String, _
                ByVal RecipientBCC As String, _
                ByVal Subject As String, _
                ByVal Body As String, _
                ByVal Attachment As String, _
                ByVal Priority As Integer, _
                ByVal MailServer As String, _
                ByVal MailServerUserName As String, _
                ByVal MailServerPassWord As String) As Boolean

        'From                 发送地址
        'Recipient            接收地址
        'RecipientCC          副本抄送
        'RecipientBCC         隐藏的副本抄送
        'Subject              邮件标题
        'Body                 邮件内容
        'Attachment           附件
        'Priority             邮件的优先程度,从1到5
        'MailServer           SMTP服务器的IP地址或名称
        'MailServerUserName   SMTP服务器用户名
        'MailServerPassWord   SMTP服务器密码

        Dim eMail As New jmail.Message
        With eMail
            .Logging = True '调用Log记录,供Debug用
            .Silent = True

            .MailServerUserName = MailServerUserName  'SMTP服务器用户名
            .MailServerPassWord = MailServerPassWord  'SMTP服务器密码
            .From = From                                  '发送地址
            .AddRecipient (Recipient)                 '接收地址
            .AddRecipientBCC (RecipientBCC)           '隐藏的副本抄送
            .AddRecipientCC (RecipientCC)                '副本抄送
            .Subject = Subject                        '邮件标题
            .Body = Body                               '邮件内容
            If Len(Attachment) > 0 Then .AddAttachment (Attachment) '附件
            .Priority = Priority

            If eMail.Send(MailServer) Then            '发送到SMTP服务器
                SendMail = True
            Else
                SendMail = False
            End If
        End With
        DoEvents
        Set eMail = Nothing    '销毁实例
End Function

  • 0
    点赞
  • 0
    收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
©️2022 CSDN 皮肤主题:大白 设计师:CSDN官方博客 返回首页
评论

打赏作者

Surpass

你的鼓励将是我创作的最大动力

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值