|
Question : Include signature when creating new e-mail from VBA command
|
|
Hi folks,
When I create a new Outlook 2003 e-mail via VBA from an Access 2003 application I would like to include my default signature (MS Word editor). If I create a new e-mail manually from within Outlook the signature is present (e.g. can right-click on it and select an alternative one if required), but not from the Access VBA code snippet below:
Set MyMail = MyOutlook.CreateItem(olMailItem) MyMail.Recipients.Add (sUserName) MyMail.Recipients.ResolveAll MyMail.Subject = "Subject line" MyMail.Body = "Message data" MyMail.Display
MSDN offers copious advice on including a digital signature but I need the human readable one.
Thanks
|
|
Answer : Include signature when creating new e-mail from VBA command
|
|
Sub Mail_Outlook_With_Signature_Html() ' Don't forget to copy the function GetBoiler in the module. ' Working in Office 2000-2007 Dim OutApp As Object Dim OutMail As Object Dim strbody As String Dim SigString As String Dim Signature As String Set OutApp = CreateObject("Outlook.Application") OutApp.Session.Logon Set OutMail = OutApp.CreateItem(0) strbody = "<H3><B>Dear Customer</B></H3>" & _ "Please visit this website to download the new version.<br>" & _ "Let me know if you have problems.<br>" & _ "<A HREF=""http://www.rondebruin.nl/"">Ron's Excel Page</A>" & _ "<br><br><B>Thank you</B>" SigString = "C:\Documents and Settings\" & Environ("username") & _ "\Application Data\Microsoft\Signatures\Mysig.htm" If Dir(SigString) <> "" Then Signature = GetBoiler(SigString) Else Signature = "" End If On Error Resume Next With OutMail .To = "[email protected]" .CC = "" .BCC = "" .Subject = "This is the Subject line" .HTMLBody = strbody & "<br><br>" & Signature 'You can add files also like this '.Attachments.Add ("C:\test.txt") .Send 'or use .Display End With
On Error GoTo 0 Set OutMail = Nothing Set OutApp = Nothing End Sub
|
|
|