[英]outlook attachment using VBA
I am trying to attach the file to my outlook. 我正在尝试将该文件附加到我的Outlook中。 However, the date of the file will change according to the days.
但是,文件的日期将根据天数而改变。 If
strlocation
is present it will be attached to outlook or else, strlocation1
should be attached to outlook. 如果存在
strlocation
,则它将附加到Outlook,否则, strlocation1
应附加到Outlook。 I am trying to do this through VBA. 我正在尝试通过VBA做到这一点。
Can someone help me to do this functionality? 有人可以帮我做这个功能吗?
Below is the code: 下面是代码:
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)
Thanks everyone for trying. 感谢大家的尝试。 I found it by myself.
我自己找到的。 Here is the code that will do my requirement.
这是满足我要求的代码。
If strLocation1 = "" Then
.Attachments.Add (strLocation1)
Else
.Attachments.Add (strLocation)
End If
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.