Insert HTML into Outlook message with Javascript

J

jeff.boggs

Hello,

I have a problem inserting HTML from a Word document into a new Outlook
mail message. The message ends up losing all of the formatting and the
image that is supposed to appear at the top of the message does not.

Here is the code for inserting the HTML.

var oOutlookApp, oWordApp, oOutlookMsg, iOutlookRunning;
iOutlookRunning = false;
var attach = "c:\\test.txt"
var attach2 = "c:\\test.txt"
var attach3= "c:\\EmailTemplate.htm";

//Create Outlook Object
oOutlookApp = new ActiveXObject("Outlook.Application");
oDoc = new ActiveXObject("Word.Application");
//Create Outlook Message
oOutlookMsg = oOutlookApp.CreateItem(0);
oOutlookMsg.BodyFormat = 2;

oDoc.Visible = false;
oDoc.Documents.Open(attach3);
iOutlookRunning = true;

oOutlookMsg.To = sText + "@inovex.ca";


oOutlookMsg.Subject = "test";
oOutlookMsg.Body = oDoc.ActiveDocument.Content;

oOutlookMsg.Attachments.Add(attach,1);
oOutlookMsg.Attachments.Add(attach2,2);
oOutlookMsg.Attachments.Add(attach3,3);

//Send Email
oOutlookMsg.Send;
 
R

RobG

Hello,

I have a problem inserting HTML from a Word document into a new Outlook
mail message. The message ends up losing all of the formatting and the
image that is supposed to appear at the top of the message does not.

I think you're lost. :)

Try an Outlook or JScript news group or support forum:

MSDN forums:
<URL:http://forums.microsoft.com/MSDN/default.aspx?SiteID=1>

Microsoft TechNet Script Center:
<URL:http://www.microsoft.com/technet/scriptcenter/default.mspx>

Outlookcode.com:
<URL:http://www.outlookcode.com/d/index.htm>

The syntax of your code looks OK from a purely ECMAScript viewpoint,
however whether it should work or not in Outlook probably wont be
answered here.

[...]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top