vba - Preserve text format when sending the content of a word document as the body of an email, -
i'm trying send content of word document body of outlook email, happens formats of texts (bold, color, etc) lost after inserted email.
i have tried using word document envelop item, , did preserve original format .display method not work under such circumstances.
below codes
bodi = wddoc3.content wdapp.activedocument .saveas thisworkbook.path & "./past email/email generated on" & "-" & format(date, "dd mmmm yyyy") & ".doc" .close end set mail_object = createobject("outlook.application") set mail_single = mail_object.createitem(0) mail_single .display end signature = mail_single.body mail_single .to = arr2(2, 1) .subject = arr2(1, 1) .cc = arr2(3, 1) .bcc = arr2(4, 1) .body = bodi & vbnewline & signature
and below code found on internet using envelop method, .display or .visible method not make outlook window pop up. directly send out email, not wanted.
set itm=wddoc3.mailenvelope.item itm .to="" .subject="" .display
the .display here not working
end
how can fix or there other ways preserve text format?
the body property of mailitem class returns or sets string representing clear-text body of outlook item. preserve formatting need use htmlbody or word editor.
the outlook object model provides 3 main ways working item bodies:
- body - string representing clear-text body of outlook item.
- htmlbody - string representing html body of specified item.
- word editor - microsoft word document object model of message being displayed. wordeditor property of inspector class returns instance of document class word object model can use set message body.
you can read more these ways in chapter 17: working item bodies.
so, can use word editor set message body without loosing formatting.
Comments
Post a Comment