Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating OlMailItem with VBA in Word

Status
Not open for further replies.

apollo911

Programmer
Nov 19, 2008
4
I'm trying to use a VBA script to generate Outlook Mail Items using a Word Document - ( a Mail Merge with Attachments) .

However the script I have uses the body tag to insert the source document text ...

.Subject = mysubject
.Body = Source.Sections(1).Range.Text

where Source is the open Word Document..

but I want to use .HTMLBody so as not to lose all formatting..

how can I include Source.Sections(1).Range.Text
in for instance a <p> tag?

I guess I'm looking for the VBA equivalent of echo in PHP
where I'd write
<p> <? echo Source.Sections(1).Range.Text ?> </p>

 
Ummm... Like this?
Code:
  .Body = "<p>" & Source.Sections(1).Range.Text & "</p>"

[tongue]

[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
If you're using Range.Text, you've lost all the formatting already - and even if you hadn't, wrapping the whole thing up in a <p> tag won't help.

Just using the HTMLBody, whilst a start, isn't enough. If memory serves - and I'm hoping somebody else can jump in and help - it's quite tricky to get the Word data in HTML format to apply to the HTMLBody attribute. Although it isn't something I like to use, you might want to look at using Cut and Paste.

Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

I'm working (slowly) on my own website
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top