Hi Marvin,
First of all you need to set Message body format to HTML or Rich Text; if it is the Plain Text format, then the formatting will be lost anyway.
I am not quite sure how to do it in Outlook2000 in which I am working (related properties like EditType are read-only there), but in Outlook2002 it seems available ("bodyformat", see
http://www.slipstick.com/dev/code/zaphtml.htm for some details and example code).
Secondly you need to preserve MsWord text formatting on the way from application to clipboard and then to message body. Paste method should help here, but where is this method in Outlook2000?
So I came up with this bulky but working example, where I use windows shell sendkeys method:
oOutLookObject = CreateObject("Outlook.Application")
oEmailItem = oOutLookObject.CreateItem(MAILITEM)
WITH oEmailItem
.To = "rubinov@juno.com"
.Subject = "Automation sample"
oword=CREATEOBJECT("word.application")
WITH oword
.Documents.Open("c:\hello.doc")
.activedocument.Range.Copy
.Quit(0)
endwith
oword=.null.
.Save
.DISPLAY
WAIT WINDOW TIMEOUT 1.0 "Wait while message is invoking..."
oShell = CreateObject("WScript.Shell")
if oShell.AppActivate(.subject+" - Message (Plain Text)")
?oShell.SendKeys("%oR")
ENDIF
WAIT WINDOW TIMEOUT 1.0 "Wait while message format is changing..."
if oShell.AppActivate(.subject+" - Message (Rich Text)") or;
oShell.AppActivate(.subject+" - Message (HTML)")
?oShell.SendKeys("{TAB}%EP")
ENDIF
oShell=.null.
susp
.......
If you are working in Outlook2002, then I hope you will find more elegant solution.
>I'm automating Outlook to email a Word Document, not as an attachment but as the subject body. Presently I'm opening the word document, copying to the clipboard, assigning the body the contents of the clipboard.
>
>Works great, except I loose all formatting. I'm just looking to keep my font name and size, nothing complicated. If I do a copy / paste between applications myself, it works great. Any ideas? Thanks!