A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Word 97 Macro to Create Outlook '03 Email With Text Format



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 5th 08, 06:15 PM posted to microsoft.public.outlook.program_vba
John Ciccone
external usenet poster
 
Posts: 15
Default Word 97 Macro to Create Outlook '03 Email With Text Format

Perhaps this should be in the Word 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 = "
'Set the recipient for a copy
.CC = "
'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


Ads
  #2  
Old May 5th 08, 09:42 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Word 97 Macro to Create Outlook '03 Email With Text Format

There's no simple solution in your scenario of mixed versions. The Body property has no formatting features. HTMLBody takes a fully formatted HTML string, but to get that HTML content from your Word document, you'd have to save the Word document as an HTML file, then read the text of that file into HTMLBody. Even then, it wouldn't handle embedded images correctly.

Your best option would be to upgrade to Office 2003 (Word and Outlook need to be from the same SKU) or better yet, 2007. Or, consider using the third-party Redemption library. See http://www.outlookcode.com/article.aspx?id=31 for more information.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"John Ciccone" wrote in message news
Perhaps this should be in the Word 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 = "
'Set the recipient for a copy
.CC = "
'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


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How can set to default the Format Text with No Spacing in Word / Outlook 2007? Michael B. Outlook - General Queries 7 November 2nd 07 12:10 AM
Outlook macro abends but Word macro runs successfully Jreue Outlook and VBA 0 December 14th 06 12:55 AM
How do I create a macro to email a file Roger Outlook and VBA 1 October 24th 06 06:20 PM
Save email as text file macro Simon Outlook and VBA 7 August 10th 06 04:10 PM
text page format on new email [email protected] Outlook - General Queries 1 July 28th 06 05:13 PM


All times are GMT +1. The time now is 12:35 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2024 Outlook Banter.
The comments are property of their posters.