Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add default signature in 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?

  1. This would be the default signature that is automatically added when creating a new email.

  2. Ideally, I'd like to just use ObjMail.GetDefaultSignature, but I can't find anything like it.

  3. 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("Scripting.FileSystemObject") Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2) GetBoiler = ts.readall ts.Close End Function 

    (Called with getboiler(SigString = "C:\Users\" & Environ("username") & "\AppData\Roaming\Microsoft\Signatures\Mysig.txt"))

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 Outlook.Application     Dim ObjMail As Outlook.MailItem      Set OlApp = Outlook.Application     Set ObjMail = OlApp.CreateItem(olMailItem)      ObjMail.BodyFormat = olFormatHTML     ObjMail.Subject = "Subject goes here"     ObjMail.Recipients.Add "Email goes here"      ObjMail.HTMLBody = ObjMail.Body & "HTML Table goes here"     ObjMail.Display  End Sub 
like image 778
PowerUser Avatar asked Jan 24 '12 21:01

PowerUser


People also ask

How do I get my signature to automatically add in Outlook 365?

Under Mail > Layout, select Email signature. In the text box, create your signature. You can modify the formatting with the mini toolbar. Check the Automatically include my signature on messages I send box to append your signature to all outgoing emails including replies and forwards.


1 Answers

The code below will create an outlook message & keep the auto signature

Dim OApp As Object, OMail As Object, signature As String  Set OApp = CreateObject("Outlook.Application") Set OMail = OApp.CreateItem(0)  With OMail     .Display End With  signature = OMail.body  With OMail     '.To = "[email protected]"     '.Subject = "Type your email subject here"     '.Attachments.Add     .body = "Add body text here" & vbNewLine & signature     '.Send End With  Set OMail = Nothing Set OApp = Nothing 
like image 181
Julia Jones Avatar answered Sep 23 '22 03:09

Julia Jones