View Single Post
  #8  
Old September 13th 06, 10:03 PM posted to microsoft.public.outlook
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Copy Text from Word Doc into E-mail message

If what you have now is:

.Attachments.Add "c:\temp\File.rtf"

then to add another attached file, you'd repeat that statement:

.Attachments.Add "c:\temp\File2.rtf"

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"gumby" wrote in message oups.com...
Going back to my attachment code at the top. How would I attach more
than one file?

Thanks,
David


Sue Mosher [MVP-Outlook] wrote:
If you want all the text, you can use the "Office envelope" feature. This code starts Word if it isn't already running, opens your document, creates a message from it, saves and sends the message, then closes Word if appropriate:

Sub SendDocAsMsg()
Dim wd As Word.Application
Dim doc As Word.Document
Dim itm As Object
Dim ID As String
Dim blnWeOpenedWord As Boolean
On Error Resume Next

Set wd = GetObject(, "Word.Application")
If wd Is Nothing Then
Set wd = CreateObject("Word.Application")
blnWeOpenedWord = True
End If
Set doc = wd.Documents.Open _
(FileName:="c:\temp\File.rtf", ReadOnly:=True)
Set itm = doc.MailEnvelope.Item
With itm
.To = "Address"
.Subject = "Subject"
.Save
ID = .EntryID
End With
Set itm = Nothing

Set itm = Application.Session.GetItemFromID(ID)
itm.Send
doc.Close wdDoNotSaveChanges
If blnWeOpenedWord Then
wd.Quit
End If

Set doc = Nothing
Set itm = Nothing
Set wd = Nothing
End Sub

Note that this is Outlook VBA code and requires a reference to the Microsoft Word library in Tools | References.

"gumby" wrote in message ups.com...
Thanks - I will check it out. I want all text and it is the word doc
that I am currently attaching. or .rtf.

David

Sue Mosher [MVP-Outlook] wrote:
What Word doc? All the text or just some?

"gumby" wrote in message ups.com...
I have the following macro to send out an e-mail with an attachment.

Sub SendMailMorning()
Set objMail = Application.CreateItem(0)
With objMail
.Subject = "Subject"
.To = "address"
.CC = "address"
.BCC = "address"
.Attachments.Add "c:\temp\File.rtf"
.Send
End With
End Sub

However I would like to be able to take the text out of the word doc
and place it into the message of the e-mail instead of attaching it. Is
this possible?


Ads