Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / February 2005

Tip: Looking for answers? Try searching our database.

emailing document through Word OLE

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
texasHawkeye - 15 Feb 2005 21:05 GMT
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 = 'sjk@xyz.com'
    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('sjk@xyz.com')
    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
Doug Robbins - 15 Feb 2005 23:12 GMT
See the article "How to send an email from Word using VBA" at:

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

Signature

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

>I am trying to send an email using Word using OLE controls.  I would like
>to
[quoted text clipped - 55 lines]
>
> Thanks
texasHawkeye - 16 Feb 2005 14:59 GMT
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.

> See the article "How to send an email from Word using VBA" at:
>
[quoted text clipped - 59 lines]
> >
> > Thanks
texasHawkeye - 16 Feb 2005 16:43 GMT
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!

> 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
[quoted text clipped - 69 lines]
> > >
> > > Thanks
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.