【发布时间】:2021-01-04 15:26:58
【问题描述】:
我正在尝试在 Outlook 中将创建的 pdf 文件附加到我的电子邮件中。除附件部分外,一切正常。
在我的代码下面找到:
Sub sendApplicationMail()
Dim strPath As String
strPath = Environ("USERPROFILE") & "\Desktop\"
ChDir strPath
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=strPath & "CreatedFile.pdf"
Dim OutLookApp As Object
Dim OutLookMailItem As Object
Dim myAttachments As Object
Set OutLookApp = CreateObject("Outlook.application")
Set OutLookMailItem = OutLookApp.CreateItem(0)
Set myAttachments = OutLookMailItem.Attachments
With OutLookMailItem
.To = "max.mustermannm@gmail.com"
.Subject = "My Data"
.Body = "Dear team" & "," & vbCrLf & "please find attached my pdf."
.myAttachments.Add strPath & "CreatedFile.pdf"
'.send
.Display
End With
Set OutLookMailItem = Nothing
Set OutLookApp = Nothing
End Sub
【问题讨论】:
-
那行会报错吗?