VBA Send Email - Keep formatting?

lionpants

Board Regular
Joined
Nov 11, 2009
Messages
117
I'm using the following in VBA to send an email using Outlook...

Code:
    Dim OutApp As Object
    Dim OutMail As Object
    Dim strbody As String

    Set OutApp = CreateObject("Outlook.Application")
    OutApp.Session.Logon
    Set OutMail = OutApp.CreateItem(0)
    
    Ray = Split(txtRequestedFor.Text, " ")

    strbody = Ray(0) & "," & Chr(10) & Chr(10) _
        & "According to our records, the deployment information for the following assets is still required." _
        & Chr(10) & Chr(10) & "Assets..." & Chr(10) & txtItemsRequested.Text & Chr(10) & Chr(10) _
        & "Serial Numbers..." & Chr(10) & txtSerials.Text & Chr(10) & Chr(10) & "Information Required..." _
        & Chr(10) & txtRequiredInfo.Text & Chr(10) & Chr(10) & "It has been " & lblDaysWaiting.Caption _
        & " days since these assets have been delivered to you.  Please provide this information ASAP." _
        & Chr(10) & Chr(10) & "Thanks in advance,"

    On Error Resume Next
    With OutMail
        .To = txtRequestedFor.Text
        .CC = ""
        .BCC = ""
        .Subject = txtWO.Text
        .Display
        .Body = strbody & .Body
    End With
    On Error GoTo 0

I .Display the email first and then add to the body so the signature appears. The only problem I am having is that the signature formatting gets reset to default. Is there anyway to keep this formatting?

Thanks!
 

Some videos you may like

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Watch MrExcel Video

Forum statistics

Threads
1,123,143
Messages
5,599,975
Members
414,354
Latest member
Flaxarn

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
Top