|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- ' 发送单个邮件的子程序
- Sub SendMail(ByVal to_who As String, ByVal subject As String, ByVal body As String, ByVal attachement As String, ByVal CC As String)
- Dim ObjOL As Object
- Dim itmNewMail As Object
- Dim mailaddress As String
- 'Dim OutMail As Outlook.MailItem
- 'Dim OutApp As Outlook.Application
- '引用Microsoft Outlook 对象
- Set ObjOL = CreateObject("Outlook.Application")
- Set itmNewMail = ObjOL.CreateItem(olMailItem)
- With itmNewMail
- .subject = subject '主旨
- .body = body '正文本文
- .To = to_who '收件者
- .Attachments.Add attachement '附件,如果你不需要发送附件,可以把这一句删掉即可,Excel中的第四列留空,不能删哦
- .CC = CC '抄送
- .SendUsingAccount = ObjOL.Session.Accounts.Item(2)
- .Display '启动Outlook发送窗口
- 'SetTimer 0, 0, 0, AddressOf WinProcA
- End With
- Set ObjOL = Nothing
- Set itmNewMail = Nothing
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|