Forum Discussion

kheldar's avatar
kheldar
Iron Contributor
May 07, 2022
Solved

VBA - .Body & .HTMLBody Indent and Default Signature Issue

Hello,

 

I've set up a macro to send an e-mail through Outlook.

 

.Body is read from a cell inside the file with indents. Since the value will change depending on the usage, I need to reference that cell for the body.

 

However, there rises 2 issues using .HTMLbody I lose indents which are constructed with CHAR(10) but I keep the default HTML signature.

 

When using just .BODY indents are displayed are correctly however the default signature is not constructed as HTML and I lose the images.

 

How should I go about fixing this issue?

 

My code:

 

 

 

sig = .HTMLBody
body = xlSht.Range("B4").Value
    .To = xlSht.Range("B2").Value
    .CC = ""
    .Subject = xlSht.Range("B1").Value
    .body = body & sig
    .Display

 

 

 
I'd really appreciate your assistance.

 

Thanks.

  • I've figured it out. I edited the cell indents(CHAR(10)) to something called "helper" then I simply used Replace function.

    .HTMLBody = Replace(body, "helper", "<br>") & sig

1 Reply

  • kheldar's avatar
    kheldar
    Iron Contributor
    I've figured it out. I edited the cell indents(CHAR(10)) to something called "helper" then I simply used Replace function.

    .HTMLBody = Replace(body, "helper", "<br>") & sig

Resources