我正在尝试使用Excel VBA发送带有附件的电子邮件。
如果我不包括附件代码行,则我的代码正在发送电子邮件。
当我写那行来发送附件时,它显示错误。
Set MyApp = CreateObject("Outlook.Application")
Set MyItem = MyApp.CreateItem(0)
With MyItem
.To = "[email protected]"
.Subject = "Subject"
.ReadReceiptRequested = False
.HTMLBody = "resport"
.Attachment = "C:\Users\saurabh.ad.sharma\Desktop\rrr.xlsx"
End With
MyItem.Send
最佳答案
一个带有附件发送邮件的简单示例
试试这个
Dim objOutl
Set objOutl = CreateObject("Outlook.Application")
Set objMailItem = objOutl.CreateItem(olMailItem)
'comment the next line if you do not want to see the outlook window
objMailItem.Display
strEmailAddr = "[email protected]"
objMailItem.Recipients.Add strEmailAddr
objMailItem.Body = "Hi"
objMailItem.Attachments.Add "file.xml"
objMailItem.Send
Set objMailItem = nothing
Set objOutl = nothing
关于excel - 使用Excel VBA发送带有附件的Outlook电子邮件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47349261/