|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
使用前先设置可以第三方发送邮件
DLL有效期到: 2023-7-31
附件:
Excel发送邮件DLL.rar
(22.94 KB, 下载次数: 162)
- Sub 发送邮件()
-
- ''' <param name="StrSendMail">发件人信息: 发邮件的信箱地址|登录密码|登陆用户名|Smtp设置|SSL设置</param>
- ''' <param name="ToAddress">收件人地址,多个收件人用[;]分开</param>
- ''' <param name="Subject">邮件主标题</param>
- ''' <param name="Body">邮件正文,换行,颜色,字体等用html标识符,如换行: BR</param>
- ''' <param name="Attachment"> 附件文件路径,多个附件用[;]分开,保证文件存在,否则不会被添加;默认是:没有</param>
- ''' <param name="CCAddress">抄送人地址,多个抄送人用[;]分开,默认是:没有</param>
- ''' <param name="BCAddress">密送人地址,多个密送人用[;]分开,默认是:没有</param>
- ''' <param name="BoolAsync">是否异步发送,默认是:否</param>
- ''' <param name="BooErrMsg">发生错误是否显示错误信息,默认是:是</param>
- ''' <param name="ZCM">授权码;试用,请输入参数值:QQ14885553</param>
- ''' <returns>BOOLEAN</returns>
- ' Public Function SendMail(ByVal StrSendMail As String, ByVal ToAddress As String, ByVal Subject As String, ByVal Body As String _
- ' , Optional ByVal Attachment As String = "", Optional ByVal CCAddress As String = "" _
- ' , Optional ByVal BCAddress As String = "", Optional ByVal BoolAsync As Boolean = False _
- ' , Optional ByVal BooErrMsg As Boolean = True, Optional ByVal ZCM As String = "") As Boolean
- '
-
- Dim SendM
- Set SH = Sheets("界面")
-
- Rem 发件人信息设置
- StrSendMail = SH.Cells(1, 2).Value '发件人Email
- StrSendMail = StrSendMail & "|" & SH.Cells(4, 2).Value '邮箱密码
- StrSendMail = StrSendMail & "|" & SH.Cells(2, 2).Value '邮箱用户名
- StrSendMail = StrSendMail & "|" & SH.Cells(3, 2).Value 'smtp服务器
- StrSendMail = StrSendMail & "|" & SH.Cells(5, 2).Value '端口
-
- Rem 邮件信息设置
- Subject = "测试邮件标题" '邮件标题
- Body = "Html格式邮件内容:<BR>测试邮件<BR>的内容" ' Html格式邮件内容"
- MailTo = "opiona@163.com" ' 收件人Email"
- FromName = "xxxx" '发件人姓名
-
- Rem 附件 可以多个
- AttachFile = ThisWorkbook.Path & "\发送邮件_成功.txt" '添加附件 第一个
- AttachFile = AttachFile & ";" & ThisWorkbook.Path & "\发送邮件_成功.txt" '添加附件 第二个 以此类推
-
- Rem 开始发送
- Set SendM = CreateObject("GTDSendMail.SendMail")
- MsgBox SendM.SendMail(StrSendMail:=StrSendMail, ToAddress:=MailTo, Subject:=Subject, Body:=Body, Attachment:=AttachFile, ZCM:="QQ14885553")
-
- Rem 仅为了展示链接设置
- Range("D2").Value = StrSendMail
-
- End Sub
复制代码
|
|