每天我都在处理日常报告。这非常耗时。基本上,我需要发送包含昨天销售额与上周和上个月销售额的简要比较的电子邮件。这工作得很好。
完成此操作后,消息将粘贴到新工作表中,然后我必须将其复制并粘贴到 Outlook 中的新电子邮件中。
是否有可能创建宏在 Outlook 中打开新邮件?这样我就可以插入我的文本了。
我可以编写宏,直接从 Excel 发送数据,但这并不是我真正想要的,因为报告的某些部分必须通过手动查看数字来完成。
提前谢谢了!
要添加ActiveWorbook
作为附件:
- 保存到特定位置
-
Use Attachments.Add
从 1 的位置添加文件
code
Sub CustomMailMessage()
Dim strFile As String
Dim OutApp As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Recipient
Dim Recipients As Recipients
Set OutApp = CreateObject("Outlook.Application")
Set objOutlookMsg = OutApp.CreateItem(olMailItem)
strFile = "C:\temp\myfile.xlsx"
ActiveWorkbook.SaveAs strFile
Set Recipients = objOutlookMsg.Recipients
Set objOutlookRecip = Recipients.Add("[email protected]")
objOutlookRecip.Type = 1
With objOutlookMsg
.SentOnBehalfOfName = "[email protected]"
.Subject = "Testing this macro"
.HTMLBody = "Testing this macro" & vbCrLf & vbCrLf
'Resolve each Recipient's name.
For Each objOutlookRecip In objOutlookMsg.Recipients
objOutlookRecip.Resolve
Next
.Attachments.Add strFile
.display
End With
'objOutlookMsg.Send
Set OutApp = Nothing
End Sub
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)