Keep Word format in Outlook E-mail body

S

Stephen Plotnick

I am able to transfer the contents of a Word document to the body of an
E-mail that is being sent via Outlook. The problem is the formatting has
disappeared.

Is there a way to transfer the information and keep the formatting. The
formatting does not have pictures; there are bulletts and indents, etc.

Thanks,
Steve
 
R

rowe_newsgroups

I am able to transfer the contents of a Word document to the body of an
E-mail that is being sent via Outlook. The problem is the formatting has
disappeared.

Is there a way to transfer the information and keep the formatting. The
formatting does not have pictures; there are bulletts and indents, etc.

Thanks,
Steve

I believe Word documents use the rtf encoding for it's text and
formating, so to mimic it in an email you would have to convert the
rtf into html first. Several people have written converters for this
so you should be able to turn up some code by searching
codeproject.com or google.

Thanks,

Seth Rowe
 
S

Stephen Plotnick

I converted the doc to an htm format (there is only one word doc)

Here is my code:

Dim WordDoc as Microsoft.Office.Interop.Word.Document
WordDoc = AppWord.Documents.Open(WordFileName)
WordContent = WordDoc.Contents.Text
WordDoc.Close()
WordDoc = Nothing
AppWord.Quit()

When I transfer WordContent to the Body of the E-mail it still is not in the
same format as in the HTM document.

Thanks,
Steve
 
R

rowe_newsgroups

I converted the doc to an htm format (there is only one word doc)

Here is my code:

Dim WordDoc as Microsoft.Office.Interop.Word.Document
WordDoc = AppWord.Documents.Open(WordFileName)
WordContent = WordDoc.Contents.Text
WordDoc.Close()
WordDoc = Nothing
AppWord.Quit()

When I transfer WordContent to the Body of the E-mail it still is not in the
same format as in the HTM document.

Thanks,

How much does the content vary and in what ways? Is it just looks or
are entire html elements missing?

Thanks,

Seth Rowe
 
S

Stephen Plotnick

I ran this with both the DOC and HTM versions of the same document.

I've been playing with this all morning and here is my code:

Dim WordDoc As Microsoft.Office.Interop.Word.Document
WordDoc = AppWord.Documents.Open(WordFileName)
WordDoc.Content.Select()
WordDoc.Content.Copy()
Dim objClipboard As IDataobject = Clipboard.GetDataObject()

'WordContent = WordDoc.Content.Text
WordContent = objClipboard.GetData(DataFormats.Html)
WordDoc.Close()
WordDoc = Nothing
AppWord.Quit()

In My E-mail routine.......

myMailItem.HTMLBody = msg

Results in E-mail.....

Version:1.0 StartHTML:0000000153 EndHTML:0000024428 StartFragment:0000020677
EndFragment:0000024388 SourceURL:file:///C:\temp\Brokers%20Letter.doc
ÂÂÂÂÂÂÂÂÂÂÂThis email is to inform you .................................

ÂÂÂÂÂÂÂÂÂÂÂAs you may know,.........................
 
R

rowe_newsgroups

I ran this with both the DOC and HTM versions of the same document.

I've been playing with this all morning and here is my code:

Dim WordDoc As Microsoft.Office.Interop.Word.Document
WordDoc = AppWord.Documents.Open(WordFileName)
WordDoc.Content.Select()
WordDoc.Content.Copy()
Dim objClipboard As IDataobject = Clipboard.GetDataObject()

'WordContent = WordDoc.Content.Text
WordContent = objClipboard.GetData(DataFormats.Html)
WordDoc.Close()
WordDoc = Nothing
AppWord.Quit()

In My E-mail routine.......

myMailItem.HTMLBody = msg

Results in E-mail.....

Version:1.0 StartHTML:0000000153 EndHTML:0000024428 StartFragment:0000020677
EndFragment:0000024388 SourceURL:file:///C:\temp\Brokers%20Letter.doc
ÂÂÂÂÂÂÂÂÂÂÂThis email is to inform you ..................................

ÂÂÂÂÂÂÂÂÂÂÂAs you may know,..........................

Can you get the document's RTF text? If so, this is what you need to
be converting to html, I don't using the DataFormats.Html will convert
the file into the required html.

Also, if the document you need to send is the same, why not rewrite
the email contents in Html to start with? Word comes with an html
editor so it shouldn't be a very big deal.

Thanks,

Seth Rowe
 
S

Stephen Plotnick

Creating the doc in HTML is probably not an option here. I just wrote the
program and a friend of mine is creating the doc and a spreadsheet of mail
recipients.

The RTF option...

I will research.

THanks,
Steve
I ran this with both the DOC and HTM versions of the same document.

I've been playing with this all morning and here is my code:

Dim WordDoc As Microsoft.Office.Interop.Word.Document
WordDoc = AppWord.Documents.Open(WordFileName)
WordDoc.Content.Select()
WordDoc.Content.Copy()
Dim objClipboard As IDataobject = Clipboard.GetDataObject()

'WordContent = WordDoc.Content.Text
WordContent = objClipboard.GetData(DataFormats.Html)
WordDoc.Close()
WordDoc = Nothing
AppWord.Quit()

In My E-mail routine.......

myMailItem.HTMLBody = msg

Results in E-mail.....

Version:1.0 StartHTML:0000000153 EndHTML:0000024428
StartFragment:0000020677
EndFragment:0000024388 SourceURL:file:///C:\temp\Brokers%20Letter.doc
ÂÂÂÂÂÂÂÂÂÂÂThis email is to inform you .................................

ÂÂÂÂÂÂÂÂÂÂÂAs you may know,.........................

Can you get the document's RTF text? If so, this is what you need to
be converting to html, I don't using the DataFormats.Html will convert
the file into the required html.

Also, if the document you need to send is the same, why not rewrite
the email contents in Html to start with? Word comes with an html
editor so it shouldn't be a very big deal.

Thanks,

Seth Rowe
 
S

Stephen Plotnick

I cannot this thing to format properly.

If I go to a new E-mail manually after running my program and hit CTRL-V it
looks perfect in the body of the E-mail.

Via my program it shows HTML code or if I use text it reads perfectly just
loses the format.

I've tried.

HTM
DOC
RTF
DOCX

formats by saving via Word 2007.

Steve
I ran this with both the DOC and HTM versions of the same document.

I've been playing with this all morning and here is my code:

Dim WordDoc As Microsoft.Office.Interop.Word.Document
WordDoc = AppWord.Documents.Open(WordFileName)
WordDoc.Content.Select()
WordDoc.Content.Copy()
Dim objClipboard As IDataobject = Clipboard.GetDataObject()

'WordContent = WordDoc.Content.Text
WordContent = objClipboard.GetData(DataFormats.Html)
WordDoc.Close()
WordDoc = Nothing
AppWord.Quit()

In My E-mail routine.......

myMailItem.HTMLBody = msg

Results in E-mail.....

Version:1.0 StartHTML:0000000153 EndHTML:0000024428
StartFragment:0000020677
EndFragment:0000024388 SourceURL:file:///C:\temp\Brokers%20Letter.doc
ÂÂÂÂÂÂÂÂÂÂÂThis email is to inform you .................................

ÂÂÂÂÂÂÂÂÂÂÂAs you may know,.........................

Can you get the document's RTF text? If so, this is what you need to
be converting to html, I don't using the DataFormats.Html will convert
the file into the required html.

Also, if the document you need to send is the same, why not rewrite
the email contents in Html to start with? Word comes with an html
editor so it shouldn't be a very big deal.

Thanks,

Seth Rowe
 

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

Top