Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP, Word, Outlook
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00240872
Message ID:
00241223
Views:
16
>I'm using VFP to drive Word and put together a long, complex document. The document has headers, bolds, tables, etc.
>
>Now I want to send this bad-boy through Outlook email. I can create the email easily enough but the Outlook email object only supports .Body = "Some text". This of course loses all of my formatting.
>
>Is there some way to get that Word document into the email message? If doing it manually, I'd highlight the Word document, Copy, and then Paste into the email. It loses some formatting but gets the job done. Is there a code equivlant for this?
>
>I do not want to send it as an attachment.
>
>Thanks,
>Todd

Todd -

I found this excerpt in the Microsoft Knowledgebase:

The Outlook user interface allows you to apply various formatting to mail messages, but when you use the Body property from Microsoft Visual Basic Scripting Edition (VBScript) or Microsoft Visual Basic for Applications, all of the text formatting is lost. This is because in the Outlook object model, the data type of the Body property is text, so it behaves no differently than other types of controls, such as a label or text box.

http://support.microsoft.com/support/kb/articles/q201/1/05.asp

Unfortunately, since the Body property is only text, you will lose the formatting.

However, here is some sample code to open a Word Doc and insert it into the message body of a new mail message.

loWord = getobject(,'Word.Application')

with loWord
.Documents.Open("D:\Test.doc")
.ActiveDocument.Range.Select
endwith

loOutlook = createobject("Outlook.Application")
newMessage = loOutlook.createitem(0)

with newMessage
.Recipients.Add("Larry Perry")
.Subject = "Word Document in Message Body"
.Body = loWord.ActiveDocument.Range
.Send
endwith

Hope this helps...

- Larry
Larry Perry II
MCAD for .NET
Previous
Reply
Map
View

Click here to load this message in the networking platform