Reply
 
Thread Tools Display Modes
  #1   Report Post  
texasHawkeye
 
Posts: n/a
Default emailing document through Word OLE

I am trying to send an email using Word using OLE controls. I would like to
duplicate File - Send To - Mail Recipient. Macros have not been helpful as
I am not sure if Word is using an Outlook add-in to do the dirty work behind
the scenes.
Here is some of what I have tried so far...
1)
ole_doc = CREATE oleobject
ole_olk = CREATE oleobject
ole_msg = CREATE oleobject
ls_filename = "C:\test.htm"

ole_doc.ConnectToNewObject("word.application")
ole_doc.visible = true
ole_doc.Documents.Open(ls_filename)
ole_olk.ConnectToNewObject("Outlook.application")
ole_msg = ole_olk.createItem(0)
ole_msg.to = '
ole_msg.subject = 'Testing subj.'
ole_msg.BodyFormat = 2 //HTML
ole_msg.HTMLBody = ole_doc.ActiveDocument.Content
ole_msg.Display
ole_doc.Documents.Close()
ole_doc.Quit()

destroy ole_doc
destroy ole_olk
destroy ole_msg
- this always strips the email of formatting, hyperlinks, and images even
though it's an HTML format

2)
ole_doc = CREATE oleobject
ls_filename = "C:\test.htm"

ole_doc.ConnectToNewObject("word.application")
ole_doc.visible = true
ole_doc.Documents.Open(ls_filename)
ole_doc.ActiveDocument.HasRoutingSlip = True
ole_doc.ActiveDocument.RoutingSlip.Subject = 'Test Subject'
ole_doc.ActiveDocument.RoutingSlip.AddRecipient('s ')
ole_doc.ActiveDocument.RoutingSlip.Delivery = 0
ole_doc.ActiveDocument.RoutingSlip.ReturnWhenDone = false
ole_doc.Options.SendMailAttach = false
ole_doc.ActiveDocument.Route
ole_doc.Documents.Close()
ole_doc.Quit()
destroy ole_doc

- this sends the email with the document as an attachment. I've tried
"ole_doc.Options.SendMailAttach = false" as well without success.

I am writing this for a PowerBuilder 10 application but would take anything
I can get at this point...

Thanks
  #2   Report Post  
Doug Robbins
 
Posts: n/a
Default

See the article "How to send an email from Word using VBA" at:

http://word.mvps.org/FAQs/InterDev/SendMail.htm


--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
"texasHawkeye" wrote in message
...
I am trying to send an email using Word using OLE controls. I would like
to
duplicate File - Send To - Mail Recipient. Macros have not been helpful
as
I am not sure if Word is using an Outlook add-in to do the dirty work
behind
the scenes.
Here is some of what I have tried so far...
1)
ole_doc = CREATE oleobject
ole_olk = CREATE oleobject
ole_msg = CREATE oleobject
ls_filename = "C:\test.htm"

ole_doc.ConnectToNewObject("word.application")
ole_doc.visible = true
ole_doc.Documents.Open(ls_filename)
ole_olk.ConnectToNewObject("Outlook.application")
ole_msg = ole_olk.createItem(0)
ole_msg.to = '
ole_msg.subject = 'Testing subj.'
ole_msg.BodyFormat = 2 //HTML
ole_msg.HTMLBody = ole_doc.ActiveDocument.Content
ole_msg.Display
ole_doc.Documents.Close()
ole_doc.Quit()

destroy ole_doc
destroy ole_olk
destroy ole_msg
- this always strips the email of formatting, hyperlinks, and images even
though it's an HTML format

2)
ole_doc = CREATE oleobject
ls_filename = "C:\test.htm"

ole_doc.ConnectToNewObject("word.application")
ole_doc.visible = true
ole_doc.Documents.Open(ls_filename)
ole_doc.ActiveDocument.HasRoutingSlip = True
ole_doc.ActiveDocument.RoutingSlip.Subject = 'Test Subject'
ole_doc.ActiveDocument.RoutingSlip.AddRecipient('s ')
ole_doc.ActiveDocument.RoutingSlip.Delivery = 0
ole_doc.ActiveDocument.RoutingSlip.ReturnWhenDone = false
ole_doc.Options.SendMailAttach = false
ole_doc.ActiveDocument.Route
ole_doc.Documents.Close()
ole_doc.Quit()
destroy ole_doc

- this sends the email with the document as an attachment. I've tried
"ole_doc.Options.SendMailAttach = false" as well without success.

I am writing this for a PowerBuilder 10 application but would take
anything
I can get at this point...

Thanks



  #3   Report Post  
texasHawkeye
 
Posts: n/a
Default

This is soooo close to what I need. I must keep the formatting and the
document can not be an attachment. Since It can't be an attachment, I can't
use the Routing Slip. And since I need the formatting, I can't use the
message.Body = ActiveDocument.Content. Is this not possible?

What about setting Word's ActiveWindow.EnvelopeVisible = True. How do I set
the .To and .Subject line this way (and never even have to open or mess with
Outlook). The ActiveWindow.EnvelopeVisible = True come from a macro when I
do a File - Send To - Mail Recipient.


"Doug Robbins" wrote:

See the article "How to send an email from Word using VBA" at:

http://word.mvps.org/FAQs/InterDev/SendMail.htm


--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
"texasHawkeye" wrote in message
...
I am trying to send an email using Word using OLE controls. I would like
to
duplicate File - Send To - Mail Recipient. Macros have not been helpful
as
I am not sure if Word is using an Outlook add-in to do the dirty work
behind
the scenes.
Here is some of what I have tried so far...
1)
ole_doc = CREATE oleobject
ole_olk = CREATE oleobject
ole_msg = CREATE oleobject
ls_filename = "C:\test.htm"

ole_doc.ConnectToNewObject("word.application")
ole_doc.visible = true
ole_doc.Documents.Open(ls_filename)
ole_olk.ConnectToNewObject("Outlook.application")
ole_msg = ole_olk.createItem(0)
ole_msg.to = '
ole_msg.subject = 'Testing subj.'
ole_msg.BodyFormat = 2 //HTML
ole_msg.HTMLBody = ole_doc.ActiveDocument.Content
ole_msg.Display
ole_doc.Documents.Close()
ole_doc.Quit()

destroy ole_doc
destroy ole_olk
destroy ole_msg
- this always strips the email of formatting, hyperlinks, and images even
though it's an HTML format

2)
ole_doc = CREATE oleobject
ls_filename = "C:\test.htm"

ole_doc.ConnectToNewObject("word.application")
ole_doc.visible = true
ole_doc.Documents.Open(ls_filename)
ole_doc.ActiveDocument.HasRoutingSlip = True
ole_doc.ActiveDocument.RoutingSlip.Subject = 'Test Subject'
ole_doc.ActiveDocument.RoutingSlip.AddRecipient('s ')
ole_doc.ActiveDocument.RoutingSlip.Delivery = 0
ole_doc.ActiveDocument.RoutingSlip.ReturnWhenDone = false
ole_doc.Options.SendMailAttach = false
ole_doc.ActiveDocument.Route
ole_doc.Documents.Close()
ole_doc.Quit()
destroy ole_doc

- this sends the email with the document as an attachment. I've tried
"ole_doc.Options.SendMailAttach = false" as well without success.

I am writing this for a PowerBuilder 10 application but would take
anything
I can get at this point...

Thanks




  #4   Report Post  
texasHawkeye
 
Posts: n/a
Default

I have tried a new direction adapted from the document listed in Doug Robbins
reply. Instead of inserting the ActiveDocuemnt.Content of a .doc into the
ole_message.Body, I...
1) saved the .doc as a .htm
2) saved that .htm as a .txt
3) inserted the ActiveDocuemnt.Content of the .txt into the
message.HTMLBody. this converts the .html text back into a readable format.
The drawback is that my images are lost in the process. I will have to
research a way to embedd these images as I haven't figured that out yet.
Thanks for the help and I hope that this solution will help someone else too!

"texasHawkeye" wrote:

This is soooo close to what I need. I must keep the formatting and the
document can not be an attachment. Since It can't be an attachment, I can't
use the Routing Slip. And since I need the formatting, I can't use the
message.Body = ActiveDocument.Content. Is this not possible?

What about setting Word's ActiveWindow.EnvelopeVisible = True. How do I set
the .To and .Subject line this way (and never even have to open or mess with
Outlook). The ActiveWindow.EnvelopeVisible = True come from a macro when I
do a File - Send To - Mail Recipient.


"Doug Robbins" wrote:

See the article "How to send an email from Word using VBA" at:

http://word.mvps.org/FAQs/InterDev/SendMail.htm


--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
"texasHawkeye" wrote in message
...
I am trying to send an email using Word using OLE controls. I would like
to
duplicate File - Send To - Mail Recipient. Macros have not been helpful
as
I am not sure if Word is using an Outlook add-in to do the dirty work
behind
the scenes.
Here is some of what I have tried so far...
1)
ole_doc = CREATE oleobject
ole_olk = CREATE oleobject
ole_msg = CREATE oleobject
ls_filename = "C:\test.htm"

ole_doc.ConnectToNewObject("word.application")
ole_doc.visible = true
ole_doc.Documents.Open(ls_filename)
ole_olk.ConnectToNewObject("Outlook.application")
ole_msg = ole_olk.createItem(0)
ole_msg.to = '
ole_msg.subject = 'Testing subj.'
ole_msg.BodyFormat = 2 //HTML
ole_msg.HTMLBody = ole_doc.ActiveDocument.Content
ole_msg.Display
ole_doc.Documents.Close()
ole_doc.Quit()

destroy ole_doc
destroy ole_olk
destroy ole_msg
- this always strips the email of formatting, hyperlinks, and images even
though it's an HTML format

2)
ole_doc = CREATE oleobject
ls_filename = "C:\test.htm"

ole_doc.ConnectToNewObject("word.application")
ole_doc.visible = true
ole_doc.Documents.Open(ls_filename)
ole_doc.ActiveDocument.HasRoutingSlip = True
ole_doc.ActiveDocument.RoutingSlip.Subject = 'Test Subject'
ole_doc.ActiveDocument.RoutingSlip.AddRecipient('s ')
ole_doc.ActiveDocument.RoutingSlip.Delivery = 0
ole_doc.ActiveDocument.RoutingSlip.ReturnWhenDone = false
ole_doc.Options.SendMailAttach = false
ole_doc.ActiveDocument.Route
ole_doc.Documents.Close()
ole_doc.Quit()
destroy ole_doc

- this sends the email with the document as an attachment. I've tried
"ole_doc.Options.SendMailAttach = false" as well without success.

I am writing this for a PowerBuilder 10 application but would take
anything
I can get at this point...

Thanks




Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can you save individual document pages as seperate word files? John Calligy Mailmerge 2 April 12th 05 09:14 AM
Boiletplates from Word Perfect linda Microsoft Word Help 1 January 28th 05 05:37 PM
WordPerfect - copying formatting Morgan Page Layout 1 January 10th 05 05:00 PM
Word 2000 - Document 1 and Document 2 always open on startup VM Microsoft Word Help 2 January 4th 05 11:54 PM
Formatting one word formats the whole document Barb Miles Formatting Long Documents 1 December 2nd 04 04:37 AM


All times are GMT +1. The time now is 12:17 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"