我正在尝试将多个文件附加到Outlook。问题是该文件将具有动态名称,因为我要保存具有特定日期的文件。我试图附加该文件(如果存在),否则请跳过该文件并将其移动到文件路径中指定的另一个文件。以下是我用来附加文件的代码。每次出现错误都会提示找不到文件路径。有人可以让我知道我在想什么吗?
strLocation = "Filepath\filename_" & Format(Now() - 3, "mm.dd.yy") & ".xlsx"", FileFormat:=xlWorkbookDefault"
strLocation = "Filepath\filename_" & Format(Now() - 1, "mm.dd.yy") & ".xlsx"", FileFormat:=xlWorkbookDefault"
strLocation1 = "Filepath\filename_" & Format(Now() - 3, "mm.dd.yy") & ".xlsx"
strLocation1 = "Filepath\filename_" & Format(Now() - 1, "mm.dd.yy") & ".xlsx"
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
Signature = OutMail.body
With OutMail
.Display
.To = ""
.CC = ""
.BCC = ""
.Subject = ""
.HTMLBody = "" &.HTMLBody
If Dir(strLocation) Then
.Attachments.Add (strLocation)
ElseIf Dir(strLocation1) Then
.Attachments.Add (strLocation1)
Else
MsgBox "No file found"
End If
End With