【发布时间】:2020-10-16 11:39:07
【问题描述】:
我需要附加目录中的文件。我尝试了多个命令。
outlook msg 保存在文件夹中,但没有附件,我需要附加它。
这是我的代码的一部分。
Dim filename, file As String
Dim folder, path As String
filename = folderpath & "\sheets\"
file = Dir(filename & x & "*.xlsx")
Dim ObjMsg As Object
'Create email
On Error Resume Next
Set olapp = GetObject(, "Outlook.Application")
If Err.Number = 429 Then
Set olapp = CreateObject("Outlook.application")
DoEvents
End If
On Error GoTo 0
Set ObjMsg = olapp.CreateItem(olMailItem)
DoEvents
ObjMsg.To = ""
ObjMsg.CC = ""
ObjMsg.Subject = ""
ObjMsg.BodyFormat = 3 'Set richtext format
Set editor = ObjMsg.GetInspector.WordEditor
editor.Content.Paste
wd.Quit SaveChanges:=False
While Len(file) > 0
ObjMsg.Attachments.Add (filename & file)
file = Dir
Wend
【问题讨论】:
-
我也尝试了以下命令,但没有任何效果。
-
您寻找
filename & x & "*.xlsx",但附加filename & file。x是什么?