Question : vba to forward html or plain text emails with additional text at front


I don't know how to manipulate HTML very well, and it is messing up my automatic email forwarding system.

The user selects an email then clicks a "ForwardButton".

The vba will forward the selected email to the correct place with a few extra paragraphs at the top.

But, I am not formatting the html properly. My code says

set newitem = selectedItem.forward
with newitem
        str = "para1

para2

para3

" & .HTMLBody
        Debug.Print str
        Debug.Print "=============================="
        .HTMLBody = str
        Debug.Print .HTMLBody
        .Subject = strEmailSubject

the resulting html in str looks like this, but my text should be embedded somewhere after DOCTYPE.

 para1

para2

para3





....... etc etc

Should I just use instr(html,) and insert the text there, or is there some more subtle stuff?

For instance if the user clicks on an email that was sent in plain text, will htmlbody contain anything?

Answer : vba to forward html or plain text emails with additional text at front

hi, rberke.

"Should I just use instr(html,) and insert the text there, or is there some more subtle stuff?"
No, the way you're doing it is correct.  Outlook will fix the HTML when it sends the message.

"will htmlbody contain anything?"
Yes.  Outlook stores three versions of each message: HTML, rich text, and plain-text.
Random Solutions  
 
programming4us programming4us