Send HTML email through Excel and Outlook 2016 with default signature

Nahuster

New Member
Joined
Apr 22, 2016
Messages
33
Hello everybody,
OK, here's the thing, I know how to send the email, problem is, when I try to add the DEFAULT signature.

If I leave it as is, the body doesn't show up, and when I get it to show the body of the message, the signature won't come up.


Code:
Sub Mail1()
    Dim OApp As Object
    Dim OMail As Object
    Dim strbody As String
    Set OApp = CreateObject("Outlook.Application")
    Set OMail = OApp.CreateItem(0)
    strbody = "<B>Hello World!</B></H3>" & _
              "Goodbye"
    On Error Resume Next
    With OMail
        .display
        .To = ""
        .CC = ""
        .BCC = ""
        .Subject = ""
        .HTMLBody = strbody & "<br>" & .HTMLBody
        .send
    End With
    On Error GoTo 0
    Set OMail = Nothing
    Set OApp = Nothing
End Sub

Can't seem to figure out how to do this, I've been trying all day, looked in the internet in many many sites, and always have the same result as with my code.
If I change the order slightly, I get it to open the email (and I can see the signature there) for a split second, and then, the body is replaced with my sting.
Is there a way to add my string without loosing the default signature?


Thank you in advance.
Cheers!
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Your code works for me in 2013 as is.

According to Rons page it works for 2016 aslo.
https://www.rondebruin.nl/win/s1/outlook/signature.htm

However his message uses HTML tags as the mail is sent as HTML.
Try using tags in the text string for the message.
It may not help but it's worth a shot.

HTML:
strbody = "<p>Hello World!< br >Goodbye</p>" 'remove spaces in br tag
 
Last edited:
Upvote 0
Your code works for me in 2013 as is.

According to Rons page it works for 2016 aslo.
https://www.rondebruin.nl/win/s1/outlook/signature.htm

However his message uses HTML tags as the mail is sent as HTML.
Try using tags in the text string for the message.
It may not help but it's worth a shot.

HTML:
strbody = "Hello World!< br >Goodbye
" 'remove spaces in br tag



Hello daverunt, thanks for the prompt reply.
Thing is, I already tried this, I didn't paste with tags, because I didn't copy the original "body", but still, using the code as is, and replacing strbody for what you wrote, makes no difference. The email appears, with signature, subject and everything else, but, body is still blank.

Any other suggestions?
Thank you.
 
Upvote 0
It's difficult to make suggestions as I'm not seeing any problem : )

I'm assuming the signature was originally set up using New Mail Item - Insert - Signature - choose default signature?

Does it work if you step through the code using F8?
When you get to .Display it should be a blank mail opened with a signature only?
It needs to be at the top of the With block as per your posted code because it needs to be displayed before it can be modified later on)
It may be that the code is rattling through to the .HTMLBody before a new blank mail is opened, in which case try sticking a delay after .Display

Code:
.Display
 Application.Wait (Now + TimeValue("0:00:02"))
 
Last edited:
Upvote 0
Hi @daverunt,

Nah, that didn't do anything... just delayed 2 seconds... haha...
I tried also
Code:
.HTMLBody = .HTMLBody & "<br>" & strbody
to see if changing places would work... nothing.
It opens the email with the default signature... no body text,
if I'm to change the placement in the code, then it opens the email with the signature, and the signature immediately after disappears and gets replaced by the body...
this is really weird and I can't find the logic of it...
 
Upvote 0

Forum statistics

Threads
1,224,817
Messages
6,181,147
Members
453,021
Latest member
Justyna P

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