是否有可能创建宏 open new message in Outlook? 所以我将能够插入我的文本 . 我能够编写将直接从Excel发送它的宏,但这不是我真正想要的,因为报告的某些部分必须通过手动查看数字来完成 .
提前谢谢了!
3 回答
4
要将 ActiveWorbook 添加为附件:
将其保存到特定位置
Use Attachments.Add 从1的位置添加文件
码
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("alias@domain.com")
objOutlookRecip.Type = 1
With objOutlookMsg
.SentOnBehalfOfName = "sales@domain.com"
.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
7
我找到了这个,它工作得很好!!!!
也许还有一件事 - 是否有可能将打开的文档作为附件附加?
Sub CustomMailMessage()
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)
Set Recipients = objOutlookMsg.Recipients
Set objOutlookRecip = Recipients.Add("alias@domain.com")
objOutlookRecip.Type = 1
objOutlookMsg.SentOnBehalfOfName = "sales@domain.com"
objOutlookMsg.Subject = "Testing this macro"
objOutlookMsg.HTMLBody = "Testing this macro" & vbCrLf & vbCrLf
'Resolve each Recipient's name.
For Each objOutlookRecip In objOutlookMsg.Recipients
objOutlookRecip.Resolve
Next
'objOutlookMsg.Send
objOutlookMsg.Display
Set OutApp = Nothing
End Sub
5
我现在无法测试它,但它会像这样:
set o = createObject("Outlook.Application")
set m = o.CreateItem(olMailItem) ' replace it with 0 if you get error here
o.show ' or .Display - not sure
3 回答
要将
ActiveWorbook
添加为附件:将其保存到特定位置
Use Attachments.Add
从1的位置添加文件码
我找到了这个,它工作得很好!!!!
也许还有一件事 - 是否有可能将打开的文档作为附件附加?
我现在无法测试它,但它会像这样:
您可以在显示之前设置o.To,o.Subject等 . 对不起,它没有经过测试,但我的家用电脑上没有Outlook,我只在工作时使用它 . 如果我没记错的话,明天我会检查一下 .