Using Outlook object to write mail - can you append standard signature?

linuxgeek

New Member
Joined
Mar 9, 2013
Messages
23
Hi,

I've done a lot of searching on X Google X Bing and the like, but found no definite answer.

I'm creating emails with the Outlook.application object, but can't find an option to insert the standard signature.

Sure you can just click the option on the menu to insert it, but by default "new messages" are set to insert the signature automatically. This doesn't happen when you create the mail in VBA.

I could get round this by including some html code in the VBA itself, but it means the signature is hard coded into the VBA or at the very least, hard coded into a cell and not friendly enough to be edited by a novice.

Bah looks like its here
vba - How to add default signature in Outlook - Stack Overflow

Stupid Bing!
 
Last edited:

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Hello.

GetInspector will do it. As calling new body will delete body with signature we need to put old- and newbody together. I have an customized email_body. But I guess you will see the trick:

Code:
Sub Send_Email_Using_VBA_1()
 Dim Email_Subject, Email_Send_From, Email_Send_To, _
 Email_Cc, Email_Bcc, Email_Body, oldBody, newBody As String
 Dim Mail_Object, Mail_Single As Variant
 
'**************************************************************************
'* sende email                                                            *
'**************************************************************************
 
 Email_Subject = "Your subject"
 Email_Send_To = "[EMAIL="you@planet.com"]you@planet.com[/EMAIL]"
 Email_Cc = ""
 Email_Bcc = ""
 Email_Body = "Dear receiver, " & vbNewLine & _
                vbNewLine & _
                "[B]bold[/B] and [COLOR=red]colored[/COLOR]"
                
 On Error GoTo err_handler
 Set Mail_Object = CreateObject("Outlook.Application.14")
 Set Mail_Single = Mail_Object.CreateItem(0)
    With Mail_Single
       .GetInspector.Activate ' Get Outlook Signature instead of .Activate we can use .Display as well
        oldBody = .HTMLBody
        newBody = .HTMLBody
       .Subject = Email_Subject
       .to = Email_Send_To
       .cc = Email_Cc
       .BCC = Email_Bcc
       .HTMLBody = Email_Body & vbCrLf & oldBody
       .Display
    End With
    
    Application.Wait (Now + TimeValue("0:00:01"))
    Application.SendKeys "%s"
err_handler:
    If Err.Description <> "" Then MsgBox Err.Description
 
 End Sub
 
Upvote 0

Forum statistics

Threads
1,213,526
Messages
6,114,122
Members
448,550
Latest member
CAT RG

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top