[英]outlook attachment using VBA
我正在尝试将该文件附加到我的Outlook中。 但是,文件的日期将根据天数而改变。 如果存在strlocation
,则它将附加到Outlook,否则, strlocation1
应附加到Outlook。 我正在尝试通过VBA做到这一点。
有人可以帮我做这个功能吗?
下面是代码:
Dim strLocation As String
Dim strLocation1 As String
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
Signature = OutMail.body
With OutMail
.Display
.To = ""
.CC = ""
.BCC = ""
.Subject = ""
.HTMLBody = "<BODY style=font-size:11pt;font-family:Calibri>Hello," & "<br>" & "<br>" & "some text." & "<br>" & "<br>" & "some text," & "<br>" & .HTMLBody
strLocation = "file location" & Format(Now() - 3, "mm.dd.yy") & ".xlsx"
strLocation1 = "file location " & Format(Now() - 1, "mm.dd.yy") & ".xlsx"
'.Attachments.Add (strLocation)
'Or .Attachments.Add(strLocation1)
感谢大家的尝试。 我自己找到的。 这是满足我要求的代码。
If strLocation1 = "" Then
.Attachments.Add (strLocation1)
Else
.Attachments.Add (strLocation)
End If
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.