PC Review


Reply
Thread Tools Rate Thread

Copy Text from Word Doc into E-mail message

 
 
gumby
Guest
Posts: n/a
 
      10th Aug 2006
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?

Thanks -

 
Reply With Quote
 
 
 
 
Sue Mosher [MVP-Outlook]
Guest
Posts: n/a
 
      22nd Aug 2006
What Word doc? All the text or just some?

FYI, there is a newsgroup specifically for general Outlook programming issues "down the hall" at microsoft.public.outlook.program_vba or, via web interface, at http://www.microsoft.com/office/comm...ok.program_vba

--
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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
>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?
>
> Thanks -
>

 
Reply With Quote
 
gumby
Guest
Posts: n/a
 
      23rd Aug 2006
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?
>
> FYI, there is a newsgroup specifically for general Outlook programming issues "down the hall" at microsoft.public.outlook.program_vba or, via web interface, at http://www.microsoft.com/office/comm...ok.program_vba
>
> --
> 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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> >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?
> >
> > Thanks -
> >


 
Reply With Quote
 
Sue Mosher [MVP-Outlook]
Guest
Posts: n/a
 
      23rd Aug 2006
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.
--
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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
>> >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?


 
Reply With Quote
 
gumby
Guest
Posts: n/a
 
      23rd Aug 2006
Thanks, it worked like a charm. Would this method be the same for other
applications?

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.
> --
> 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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> >> >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?


 
Reply With Quote
 
Sue Mosher [MVP-Outlook]
Guest
Posts: n/a
 
      23rd Aug 2006
Excel also supports this technique, so you could rewrite it to use Excel objects instead of Word.

--
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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> Thanks, it worked like a charm. Would this method be the same for other
> applications?
>
> 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.


 
Reply With Quote
 
gumby
Guest
Posts: n/a
 
      13th Sep 2006
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.
> --
> 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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> >> >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?


 
Reply With Quote
 
Sue Mosher [MVP-Outlook]
Guest
Posts: n/a
 
      13th Sep 2006
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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
>> > 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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
>> >> >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?

>

 
Reply With Quote
 
gumby
Guest
Posts: n/a
 
      13th Sep 2006
I thought I had tried that before. It worked and Thank you tons.

David
Sue Mosher [MVP-Outlook] wrote:
> 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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> >> > 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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> >> >> >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?

> >


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: auto copy text in word to another text field in word Anne Troy Microsoft Word New Users 12 9th Apr 2008 12:04 AM
copy an existing e-mail message into a new e-mail message copying e-mail messages Microsoft Outlook Discussion 3 28th Nov 2007 05:44 PM
When I copy text, Word pastes a print screen - not the text I copi =?Utf-8?B?Ymlzc3kx?= Microsoft Word Document Management 1 22nd Apr 2005 01:16 AM
Copy text from WORD to the message body =?Utf-8?B?RGFu?= Microsoft Outlook Discussion 0 28th Oct 2004 02:47 PM
Using Outlook 2002/Word 2002 - Mail Merge - need text in the message with bold, underlines, and colored text,..need it to look pretty =?Utf-8?B?Um96enp6?= Microsoft Outlook 0 17th Feb 2004 02:51 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:58 PM.