2023年12月6日发(作者:)
vba添加outlook签名,如何添加默认的签名在Outlook
I am writing a VBA script in Access that creates and auto-populates a few dozen emails. It's been smooth coding so far, but
I'm new to Outlook. After creating the mailitem object, how do I add the default signature to the email?
This would be the default signature that is automatically added when creating a new email.
Ideally, I'd like to just use aultSignature, but I can't find anything like it.
Currently, I'm using the function below (found elsewhere on the internet) and referencing the exact path & filename of the
htm file. But this will be used by several people and they may have a different name for their default htm signature file. So
this works, but it's not ideal:
Function GetBoiler(ByVal sFile As String) As String
'Dick Kusleika
Dim fso As Object
Dim ts As Object
Set fso = CreateObject("stemObject")
Set ts = e(sFile).OpenAsTextStream(1, -2)
GetBoiler = l
End Function
(Called with getboiler(SigString = "C:Users" & Environ("username") &
""))
Edit
Thanks to JP (see comments), I realize that the default signature is showing up at first, but it disappears when I use
HTMLBody to add a table to the email. So I guess my question is now: How do I display the default signature and still display
an html table?
Sub X()
Dim OlApp As ation
Dim ObjMail As em
Set OlApp = ation
Set ObjMail = Item(olMailItem)
rmat = olFormatHTML
t = "Subject goes here"
"Email goes here"
dy = & "HTML Table goes here"
y
End Sub
解决方案
The code below will create an outlook message & keep the auto signatureDim OApp As Object, OMail As Object, signature As StringSet OApp = CreateObject("ation")Set OMail = Item(0)With yEnd Withsignature = th OMail'.To = "someone@"'.Subject = "Type your email subject here"'. = "Add body text here" & vbNewLine & signature'.SendEnd WithSet OMail = NothingSet OApp = Nothing


发布评论