Perhaps this should be in the Outlook discussion group, but I use a Word 97
macro that creates an email with Outlook 2003.

That email uses the contents of the current Word document as the body of the
email.

Test formatting is lost in the process. Any way to maintain (bold,
underline, colour, etc.)?

Thank you.

PS: The macro is from http://word.mvps.org/FAQs/InterDev/SendMail.htm:

Sub SendDocumentInMail()

Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem

On Error Resume Next

'Get Outlook if it's running
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
'Outlook wasn't running, start it from code
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If

'Create a new mailitem
Set oItem = oOutlookApp.CreateItem(olMailItem)

With oItem
'Set the recipient for the new email
.To = "recipient@mail.com"
'Set the recipient for a copy
.CC = "recipient2@mail.com"
'Set the subject
.Subject = "New subject"
'The content of the document is used as the body for the email
.Body = ActiveDocument.Content
.Send
End With

If bStarted Then
'If we started Outlook from code, then close it
oOutlookApp.Quit
End If

'Clean up
Set oItem = Nothing
Set oOutlookApp = Nothing

End Sub

Re: Word 97 Macro to Create Outlook '03 Email With Text Format by Doug

Doug
Mon May 05 12:43:46 PDT 2008

Try using

ActiveDocument.Range.FormattedText

instead of

ActiveDocument.Content

but as you have no control over how the recipient views their email (many
prudent users will view them as plain text), you cannot be sure how it will
be seen by the recipient. Better to send the document as an attachment, and
really better to send it as a .pdf file unless the recipient needs to be
able to edit it which is probably not the case as you are sending it as the
body of an email message.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"John Ciccone" <JohnCiccone@discussions.microsoft.com> wrote in message
news:D36549A8-7204-417B-8720-98E5B353CBEC@microsoft.com...
> Perhaps this should be in the Outlook discussion group, but I use a Word
> 97
> macro that creates an email with Outlook 2003.
>
> That email uses the contents of the current Word document as the body of
> the
> email.
>
> Test formatting is lost in the process. Any way to maintain (bold,
> underline, colour, etc.)?
>
> Thank you.
>
> PS: The macro is from http://word.mvps.org/FAQs/InterDev/SendMail.htm:
>
> Sub SendDocumentInMail()
>
> Dim bStarted As Boolean
> Dim oOutlookApp As Outlook.Application
> Dim oItem As Outlook.MailItem
>
> On Error Resume Next
>
> 'Get Outlook if it's running
> Set oOutlookApp = GetObject(, "Outlook.Application")
> If Err <> 0 Then
> 'Outlook wasn't running, start it from code
> Set oOutlookApp = CreateObject("Outlook.Application")
> bStarted = True
> End If
>
> 'Create a new mailitem
> Set oItem = oOutlookApp.CreateItem(olMailItem)
>
> With oItem
> 'Set the recipient for the new email
> .To = "recipient@mail.com"
> 'Set the recipient for a copy
> .CC = "recipient2@mail.com"
> 'Set the subject
> .Subject = "New subject"
> 'The content of the document is used as the body for the email
> .Body = ActiveDocument.Content
> .Send
> End With
>
> If bStarted Then
> 'If we started Outlook from code, then close it
> oOutlookApp.Quit
> End If
>
> 'Clean up
> Set oItem = Nothing
> Set oOutlookApp = Nothing
>
> End Sub
>
>



Re: Word 97 Macro to Create Outlook '03 Email With Text Format by JohnCiccone

JohnCiccone
Mon May 05 14:01:00 PDT 2008

Thanks, Doug.

Unfortunately it doesn't work. Strange as may seem I've got reasons to send
email with formatted text in the body of the email.

Any way to do this with HTML tags? I could certainly add to the active
document, but I don't know how to save it... IOW I end up with an email with
"<b>Hello</b>" in it.

"Doug Robbins - Word MVP" wrote:

> Try using
>
> ActiveDocument.Range.FormattedText
>
> instead of
>
> ActiveDocument.Content
>
> but as you have no control over how the recipient views their email (many
> prudent users will view them as plain text), you cannot be sure how it will
> be seen by the recipient. Better to send the document as an attachment, and
> really better to send it as a .pdf file unless the recipient needs to be
> able to edit it which is probably not the case as you are sending it as the
> body of an email message.
>
> --
> Hope this helps.
>
> Please reply to the newsgroup unless you wish to avail yourself of my
> services on a paid consulting basis.
>
> Doug Robbins - Word MVP
>
> "John Ciccone" <JohnCiccone@discussions.microsoft.com> wrote in message
> news:D36549A8-7204-417B-8720-98E5B353CBEC@microsoft.com...
> > Perhaps this should be in the Outlook discussion group, but I use a Word
> > 97
> > macro that creates an email with Outlook 2003.
> >
> > That email uses the contents of the current Word document as the body of
> > the
> > email.
> >
> > Test formatting is lost in the process. Any way to maintain (bold,
> > underline, colour, etc.)?
> >
> > Thank you.
> >
> > PS: The macro is from http://word.mvps.org/FAQs/InterDev/SendMail.htm:
> >
> > Sub SendDocumentInMail()
> >
> > Dim bStarted As Boolean
> > Dim oOutlookApp As Outlook.Application
> > Dim oItem As Outlook.MailItem
> >
> > On Error Resume Next
> >
> > 'Get Outlook if it's running
> > Set oOutlookApp = GetObject(, "Outlook.Application")
> > If Err <> 0 Then
> > 'Outlook wasn't running, start it from code
> > Set oOutlookApp = CreateObject("Outlook.Application")
> > bStarted = True
> > End If
> >
> > 'Create a new mailitem
> > Set oItem = oOutlookApp.CreateItem(olMailItem)
> >
> > With oItem
> > 'Set the recipient for the new email
> > .To = "recipient@mail.com"
> > 'Set the recipient for a copy
> > .CC = "recipient2@mail.com"
> > 'Set the subject
> > .Subject = "New subject"
> > 'The content of the document is used as the body for the email
> > .Body = ActiveDocument.Content
> > .Send
> > End With
> >
> > If bStarted Then
> > 'If we started Outlook from code, then close it
> > oOutlookApp.Quit
> > End If
> >
> > 'Clean up
> > Set oItem = Nothing
> > Set oOutlookApp = Nothing
> >
> > End Sub
> >
> >
>
>
>

Re: Word 97 Macro to Create Outlook '03 Email With Text Format by Graham

Graham
Mon May 05 23:58:38 PDT 2008

A similar issue came up recently for sending formatted e-mails with Outlook
2007 and in theory at least it may work for you as long as you add the
Outlook object library to your template. The macro creates an Outlook
message with the clipboard content as the body. If it works for you it would
be simple enough to add the code to copy the document content first. I did
find that the macro crashed Word is Outlook was not already open when run
onb my system. Others had more success. At least it may point a way forward,

Sub Send_Extract_As_EMail()
' send the document in an Outlook Email message
' 2007 Graham Mayor, Tony Jollans, Doug Robbins
' & Sue Mosher

Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
Dim objDoc As Word.Document
Dim strEMail As String

strEMail = "<PR_EMAIL_ADDRESS>"
'Let the user choose the contact from Outlook
'And assign the email address to a variable

strEMail = Application.GetAddress("", strEMail, _
False, 1, , , True, True)
If strEMail = "" Then
MsgBox "User cancelled or no address listed", , "Cancel"
End If

On Error Resume Next

'Get Outlook if it's running
Set oOutlookApp = GetObject(, "Outlook.Application")

'Outlook wasn't running, start it from code
If Err <> 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If

'Create a new mailitem
Set oItem = oOutlookApp.CreateItem(olMailItem)
Set objDoc = oItem.GetInspector.WordEditor
With oItem
.To = strEMail
.Subject = InputBox("Subject?")
Selection.Copy
objDoc.Range.Paste
.Display
End With

'Clean up
Set oItem = Nothing
Set oOutlookApp = Nothing
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


John Ciccone wrote:
> Thanks, Doug.
>
> Unfortunately it doesn't work. Strange as may seem I've got reasons
> to send email with formatted text in the body of the email.
>
> Any way to do this with HTML tags? I could certainly add to the active
> document, but I don't know how to save it... IOW I end up with an
> email with "<b>Hello</b>" in it.
>
> "Doug Robbins - Word MVP" wrote:
>
>> Try using
>>
>> ActiveDocument.Range.FormattedText
>>
>> instead of
>>
>> ActiveDocument.Content
>>
>> but as you have no control over how the recipient views their email
>> (many prudent users will view them as plain text), you cannot be
>> sure how it will be seen by the recipient. Better to send the
>> document as an attachment, and really better to send it as a .pdf
>> file unless the recipient needs to be able to edit it which is
>> probably not the case as you are sending it as the body of an email
>> message.
>>
>> --
>> Hope this helps.
>>
>> Please reply to the newsgroup unless you wish to avail yourself of my
>> services on a paid consulting basis.
>>
>> Doug Robbins - Word MVP
>>
>> "John Ciccone" <JohnCiccone@discussions.microsoft.com> wrote in
>> message news:D36549A8-7204-417B-8720-98E5B353CBEC@microsoft.com...
>>> Perhaps this should be in the Outlook discussion group, but I use a
>>> Word 97
>>> macro that creates an email with Outlook 2003.
>>>
>>> That email uses the contents of the current Word document as the
>>> body of the
>>> email.
>>>
>>> Test formatting is lost in the process. Any way to maintain (bold,
>>> underline, colour, etc.)?
>>>
>>> Thank you.
>>>
>>> PS: The macro is from
>>> http://word.mvps.org/FAQs/InterDev/SendMail.htm:
>>>
>>> Sub SendDocumentInMail()
>>>
>>> Dim bStarted As Boolean
>>> Dim oOutlookApp As Outlook.Application
>>> Dim oItem As Outlook.MailItem
>>>
>>> On Error Resume Next
>>>
>>> 'Get Outlook if it's running
>>> Set oOutlookApp = GetObject(, "Outlook.Application")
>>> If Err <> 0 Then
>>> 'Outlook wasn't running, start it from code
>>> Set oOutlookApp = CreateObject("Outlook.Application")
>>> bStarted = True
>>> End If
>>>
>>> 'Create a new mailitem
>>> Set oItem = oOutlookApp.CreateItem(olMailItem)
>>>
>>> With oItem
>>> 'Set the recipient for the new email
>>> .To = "recipient@mail.com"
>>> 'Set the recipient for a copy
>>> .CC = "recipient2@mail.com"
>>> 'Set the subject
>>> .Subject = "New subject"
>>> 'The content of the document is used as the body for the email
>>> .Body = ActiveDocument.Content
>>> .Send
>>> End With
>>>
>>> If bStarted Then
>>> 'If we started Outlook from code, then close it
>>> oOutlookApp.Quit
>>> End If
>>>
>>> 'Clean up
>>> Set oItem = Nothing
>>> Set oOutlookApp = Nothing
>>>
>>> End Sub



Re: Word 97 Macro to Create Outlook '03 Email With Text Format by JohnCiccone

JohnCiccone
Sat May 10 14:59:02 PDT 2008

Thank you, Graham. But I can't even get close. Word does crash. Stepping
through the macro the last thing I can do is:

strEMail = Application.GetAddress("", strEMail, _

I have Outlook open. I've added the Reference "Microsoft Outlook 11.0 Object
Library"

Think I'm missing something?

"Graham Mayor" wrote:

> A similar issue came up recently for sending formatted e-mails with Outlook
> 2007 and in theory at least it may work for you as long as you add the
> Outlook object library to your template. The macro creates an Outlook
> message with the clipboard content as the body. If it works for you it would
> be simple enough to add the code to copy the document content first. I did
> find that the macro crashed Word is Outlook was not already open when run
> onb my system. Others had more success. At least it may point a way forward,
>
> Sub Send_Extract_As_EMail()
> ' send the document in an Outlook Email message
> ' 2007 Graham Mayor, Tony Jollans, Doug Robbins
> ' & Sue Mosher
>
> Dim bStarted As Boolean
> Dim oOutlookApp As Outlook.Application
> Dim oItem As Outlook.MailItem
> Dim objDoc As Word.Document
> Dim strEMail As String
>
> strEMail = "<PR_EMAIL_ADDRESS>"
> 'Let the user choose the contact from Outlook
> 'And assign the email address to a variable
>
> strEMail = Application.GetAddress("", strEMail, _
> False, 1, , , True, True)
> If strEMail = "" Then
> MsgBox "User cancelled or no address listed", , "Cancel"
> End If
>
> On Error Resume Next
>
> 'Get Outlook if it's running
> Set oOutlookApp = GetObject(, "Outlook.Application")
>
> 'Outlook wasn't running, start it from code
> If Err <> 0 Then
> Set oOutlookApp = CreateObject("Outlook.Application")
> bStarted = True
> End If
>
> 'Create a new mailitem
> Set oItem = oOutlookApp.CreateItem(olMailItem)
> Set objDoc = oItem.GetInspector.WordEditor
> With oItem
> .To = strEMail
> .Subject = InputBox("Subject?")
> Selection.Copy
> objDoc.Range.Paste
> .Display
> End With
>
> 'Clean up
> Set oItem = Nothing
> Set oOutlookApp = Nothing
> End Sub
>
>
> --
> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
> Graham Mayor - Word MVP
>
> My web site www.gmayor.com
> Word MVP web site http://word.mvps.org
> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>
>
> John Ciccone wrote:
> > Thanks, Doug.
> >
> > Unfortunately it doesn't work. Strange as may seem I've got reasons
> > to send email with formatted text in the body of the email.
> >
> > Any way to do this with HTML tags? I could certainly add to the active
> > document, but I don't know how to save it... IOW I end up with an
> > email with "<b>Hello</b>" in it.
> >
> > "Doug Robbins - Word MVP" wrote:
> >
> >> Try using
> >>
> >> ActiveDocument.Range.FormattedText
> >>
> >> instead of
> >>
> >> ActiveDocument.Content
> >>
> >> but as you have no control over how the recipient views their email
> >> (many prudent users will view them as plain text), you cannot be
> >> sure how it will be seen by the recipient. Better to send the
> >> document as an attachment, and really better to send it as a .pdf
> >> file unless the recipient needs to be able to edit it which is
> >> probably not the case as you are sending it as the body of an email
> >> message.
> >>
> >> --
> >> Hope this helps.
> >>
> >> Please reply to the newsgroup unless you wish to avail yourself of my
> >> services on a paid consulting basis.
> >>
> >> Doug Robbins - Word MVP
> >>
> >> "John Ciccone" <JohnCiccone@discussions.microsoft.com> wrote in
> >> message news:D36549A8-7204-417B-8720-98E5B353CBEC@microsoft.com...
> >>> Perhaps this should be in the Outlook discussion group, but I use a
> >>> Word 97
> >>> macro that creates an email with Outlook 2003.
> >>>
> >>> That email uses the contents of the current Word document as the
> >>> body of the
> >>> email.
> >>>
> >>> Test formatting is lost in the process. Any way to maintain (bold,
> >>> underline, colour, etc.)?
> >>>
> >>> Thank you.
> >>>
> >>> PS: The macro is from
> >>> http://word.mvps.org/FAQs/InterDev/SendMail.htm:
> >>>
> >>> Sub SendDocumentInMail()
> >>>
> >>> Dim bStarted As Boolean
> >>> Dim oOutlookApp As Outlook.Application
> >>> Dim oItem As Outlook.MailItem
> >>>
> >>> On Error Resume Next
> >>>
> >>> 'Get Outlook if it's running
> >>> Set oOutlookApp = GetObject(, "Outlook.Application")
> >>> If Err <> 0 Then
> >>> 'Outlook wasn't running, start it from code
> >>> Set oOutlookApp = CreateObject("Outlook.Application")
> >>> bStarted = True
> >>> End If
> >>>
> >>> 'Create a new mailitem
> >>> Set oItem = oOutlookApp.CreateItem(olMailItem)
> >>>
> >>> With oItem
> >>> 'Set the recipient for the new email
> >>> .To = "recipient@mail.com"
> >>> 'Set the recipient for a copy
> >>> .CC = "recipient2@mail.com"
> >>> 'Set the subject
> >>> .Subject = "New subject"
> >>> 'The content of the document is used as the body for the email
> >>> .Body = ActiveDocument.Content
> >>> .Send
> >>> End With
> >>>
> >>> If bStarted Then
> >>> 'If we started Outlook from code, then close it
> >>> oOutlookApp.Quit
> >>> End If
> >>>
> >>> 'Clean up
> >>> Set oItem = Nothing
> >>> Set oOutlookApp = Nothing
> >>>
> >>> End Sub
>
>
>

Re: Word 97 Macro to Create Outlook '03 Email With Text Format by Graham

Graham
Sat May 10 22:04:04 PDT 2008

The full line is actually

strEMail = Application.GetAddress("", strEMail, False, 1, , , True, True)

which I had wrapped to avoid problems with the e-mail editor. If the
corrected line doesn't work it may be that Word 97 does not have all the
hooks necessary in the VBA implementation to allow this to work. I did say
that 'in theory' it should work - but it was an untested theory as I don't
have access to Word 97.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>



John Ciccone wrote:
> Thank you, Graham. But I can't even get close. Word does crash.
> Stepping through the macro the last thing I can do is:
>
> strEMail = Application.GetAddress("", strEMail, _
>
> I have Outlook open. I've added the Reference "Microsoft Outlook 11.0
> Object Library"
>
> Think I'm missing something?
>
> "Graham Mayor" wrote:
>
>> A similar issue came up recently for sending formatted e-mails with
>> Outlook 2007 and in theory at least it may work for you as long as
>> you add the Outlook object library to your template. The macro
>> creates an Outlook message with the clipboard content as the body.
>> If it works for you it would be simple enough to add the code to
>> copy the document content first. I did find that the macro crashed
>> Word is Outlook was not already open when run onb my system. Others
>> had more success. At least it may point a way forward,
>>
>> Sub Send_Extract_As_EMail()
>> ' send the document in an Outlook Email message
>> ' 2007 Graham Mayor, Tony Jollans, Doug Robbins
>> ' & Sue Mosher
>>
>> Dim bStarted As Boolean
>> Dim oOutlookApp As Outlook.Application
>> Dim oItem As Outlook.MailItem
>> Dim objDoc As Word.Document
>> Dim strEMail As String
>>
>> strEMail = "<PR_EMAIL_ADDRESS>"
>> 'Let the user choose the contact from Outlook
>> 'And assign the email address to a variable
>>
>> strEMail = Application.GetAddress("", strEMail, _
>> False, 1, , , True, True)
>> If strEMail = "" Then
>> MsgBox "User cancelled or no address listed", , "Cancel"
>> End If
>>
>> On Error Resume Next
>>
>> 'Get Outlook if it's running
>> Set oOutlookApp = GetObject(, "Outlook.Application")
>>
>> 'Outlook wasn't running, start it from code
>> If Err <> 0 Then
>> Set oOutlookApp = CreateObject("Outlook.Application")
>> bStarted = True
>> End If
>>
>> 'Create a new mailitem
>> Set oItem = oOutlookApp.CreateItem(olMailItem)
>> Set objDoc = oItem.GetInspector.WordEditor
>> With oItem
>> .To = strEMail
>> .Subject = InputBox("Subject?")
>> Selection.Copy
>> objDoc.Range.Paste
>> .Display
>> End With
>>
>> 'Clean up
>> Set oItem = Nothing
>> Set oOutlookApp = Nothing
>> End Sub
>>
>>
>> --
>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>> Graham Mayor - Word MVP
>>
>> My web site www.gmayor.com
>> Word MVP web site http://word.mvps.org
>> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>>
>>
>> John Ciccone wrote:
>>> Thanks, Doug.
>>>
>>> Unfortunately it doesn't work. Strange as may seem I've got reasons
>>> to send email with formatted text in the body of the email.
>>>
>>> Any way to do this with HTML tags? I could certainly add to the
>>> active document, but I don't know how to save it... IOW I end up
>>> with an email with "<b>Hello</b>" in it.
>>>
>>> "Doug Robbins - Word MVP" wrote:
>>>
>>>> Try using
>>>>
>>>> ActiveDocument.Range.FormattedText
>>>>
>>>> instead of
>>>>
>>>> ActiveDocument.Content
>>>>
>>>> but as you have no control over how the recipient views their email
>>>> (many prudent users will view them as plain text), you cannot be
>>>> sure how it will be seen by the recipient. Better to send the
>>>> document as an attachment, and really better to send it as a .pdf
>>>> file unless the recipient needs to be able to edit it which is
>>>> probably not the case as you are sending it as the body of an email
>>>> message.
>>>>
>>>> --
>>>> Hope this helps.
>>>>
>>>> Please reply to the newsgroup unless you wish to avail yourself of
>>>> my services on a paid consulting basis.
>>>>
>>>> Doug Robbins - Word MVP
>>>>
>>>> "John Ciccone" <JohnCiccone@discussions.microsoft.com> wrote in
>>>> message news:D36549A8-7204-417B-8720-98E5B353CBEC@microsoft.com...
>>>>> Perhaps this should be in the Outlook discussion group, but I use
>>>>> a Word 97
>>>>> macro that creates an email with Outlook 2003.
>>>>>
>>>>> That email uses the contents of the current Word document as the
>>>>> body of the
>>>>> email.
>>>>>
>>>>> Test formatting is lost in the process. Any way to maintain (bold,
>>>>> underline, colour, etc.)?
>>>>>
>>>>> Thank you.
>>>>>
>>>>> PS: The macro is from
>>>>> http://word.mvps.org/FAQs/InterDev/SendMail.htm:
>>>>>
>>>>> Sub SendDocumentInMail()
>>>>>
>>>>> Dim bStarted As Boolean
>>>>> Dim oOutlookApp As Outlook.Application
>>>>> Dim oItem As Outlook.MailItem
>>>>>
>>>>> On Error Resume Next
>>>>>
>>>>> 'Get Outlook if it's running
>>>>> Set oOutlookApp = GetObject(, "Outlook.Application")
>>>>> If Err <> 0 Then
>>>>> 'Outlook wasn't running, start it from code
>>>>> Set oOutlookApp = CreateObject("Outlook.Application")
>>>>> bStarted = True
>>>>> End If
>>>>>
>>>>> 'Create a new mailitem
>>>>> Set oItem = oOutlookApp.CreateItem(olMailItem)
>>>>>
>>>>> With oItem
>>>>> 'Set the recipient for the new email
>>>>> .To = "recipient@mail.com"
>>>>> 'Set the recipient for a copy
>>>>> .CC = "recipient2@mail.com"
>>>>> 'Set the subject
>>>>> .Subject = "New subject"
>>>>> 'The content of the document is used as the body for the email
>>>>> .Body = ActiveDocument.Content
>>>>> .Send
>>>>> End With
>>>>>
>>>>> If bStarted Then
>>>>> 'If we started Outlook from code, then close it
>>>>> oOutlookApp.Quit
>>>>> End If
>>>>>
>>>>> 'Clean up
>>>>> Set oItem = Nothing
>>>>> Set oOutlookApp = Nothing
>>>>>
>>>>> End Sub