我正在尝试使用VB脚本发送带附件的电子邮件。
我的代码成功运行并发送电子邮件,如果我不在我的代码中包含附件发送代码行,但当我写这行发送附件时,它显示错误,请指导我这个
以下是我发送带附件的电子邮件的代码,但它是"没有工作"。
Set MyApp = CreateObject("Outlook.Application")
Set MyItem = MyApp.CreateItem(0)
With MyItem
.To = "saurabh.ad.sharma@accenture.com"
.Subject = "Subject"
.ReadReceiptRequested = False
.HTMLBody = "resport"
.Attachment = "C:\Users\saurabh.ad.sharma\Desktop\rrr.xlsx"
End With
MyItem.Send
答案 0 :(得分:4)
使用附件发送邮件的简单示例 试试这个
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 = "me.me@you.com"
objMailItem.Recipients.Add strEmailAddr
objMailItem.Body = "Hi"
objMailItem.Attachments.Add "file.xml"
objMailItem.Send
Set objMailItem = nothing
Set objOutl = nothing