Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub 发送邮件()
- '保存当前excel
- ThisWorkbook.Save
- '让excel沟通outlook 要将工具/引用中的Microseft Outlook *.0 Object Library(其中*为你Microseft Outlook的版本号)选上
- Dim 信差 As Outlook.Application
- Set 信差 = New Outlook.Application
- '创建邮件实例
- Dim 新邮件 As MailItem
- Set 新邮件 = 信差.CreateItem(olMailItem)
- Dim filePath As String
- filePath = ThisWorkbook.FullName
- 'MsgBox filePath
- With 新邮件
- '设置收件人地址
- .To = "small-bao@foxmail.com"
- '设置抄送收件人地址
- .CC = ""
- '设置邮件主题
- .Subject = Date & " K/B复判报表"
- '设置邮件内容
- .Body = Date & " K/B复判报表"
- '设置附件
- .Attachments.Add (filePath)
- '显示UI
- .Display
- '发送邮件
- '.Send
- End With
- ' 清理
- Set 新邮件 = Nothing
- Set 信差 = Nothing
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement