【发布时间】:2019-02-11 13:08:00
【问题描述】:
我编写了这个非常简单的代码来在我的电子邮件中附加一个文件,但是电子邮件没有附件。
它甚至不会抛出任何错误。我已确保路径正确且文件存在。 请帮忙
Private Sub CommandButton2_Click()
On Error GoTo ErrHandler
' SET Outlook APPLICATION OBJECT.
Dim objOutlook As Object
Set objOutlook = CreateObject("Outlook.Application")
Dim Source_File As String
' CREATE EMAIL OBJECT.
Dim objEmail As Object
Set objEmail = objOutlook.CreateItem(olMailItem)
With objEmail
.To = "arushi.agarwal@in.ab-inbev.com"
.Subject = "This is a test message k"
.Body = "Please use this template for your weekly meeting today"
.Send ' SEND MESSAGE.
.AddAttachment ("C:\Claims\Try.docx")
End With
' CLEAR.
Set objEmail = Nothing: Set objOutlook = Nothing
ErrHandler:
'
End Sub
【问题讨论】:
-
嗨 Arushi,您可以尝试使用 .Attachments.Add("C:\Claims\Try.docx") 而不是 .AddAttachment ("C:\Claims\Try.docx")
-
您在添加附件之前发送电子邮件。
-
@Don't now Outlook,但也许你应该在 .AddAttachment.., 行下面写 .Send。
-
天啊,我真傻。十分感谢大家。这真的很有帮助。