PC Review Forums Newsgroups Microsoft Outlook Microsoft Outlook VBA Programming need Outlook 2002 macro to change mail format

Reply

need Outlook 2002 macro to change mail format

 
Thread Tools Rate Thread
Old 13-03-2006, 03:52 PM   #1
=?Utf-8?B?TWF1cmVlbg==?=
Guest
 
Posts: n/a
Default need Outlook 2002 macro to change mail format


I need to create a macro in Outlook 2002 to change the mail format from HTML
to rich text and another to change it back to HTML. Can anyone help?
--
Maureen
  Reply With Quote
Old 14-03-2006, 06:56 PM   #2
=?Utf-8?B?RXJpYyBMZWdhdWx0IFtNVlAgLSBPdXRsb29rXQ==
Guest
 
Posts: n/a
Default RE: need Outlook 2002 macro to change mail format

Hi Maureen. If you're dealing with these settings at a program level, see my
post here:

Outlook's Message Format Settings In The Registry:
http://blogs.officezealot.com/legau...08/03/1324.aspx

For a specific message, you will have to automate clicking the choices under
the Format menu by using CommandBar and CommandBarButton objects from the
Office Object Model. However, you have to switch to Plain Text in between.
So HTML -> Plain Text -> Rich Text -> Plain Text -> HTML. Why do you need to
do this?

--
Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"Maureen" wrote:

> I need to create a macro in Outlook 2002 to change the mail format from HTML
> to rich text and another to change it back to HTML. Can anyone help?
> --
> Maureen

  Reply With Quote
Old 14-03-2006, 11:25 PM   #3
=?Utf-8?B?TWF1cmVlbg==?=
Guest
 
Posts: n/a
Default RE: need Outlook 2002 macro to change mail format

I was asked to create a series of documents in Word that includes data pasted
from the clipboard when the Word macro is run. To satisfy all the
requirements, I changed the Outlook mail format to HTML using MS Word to Edit
Email Msgs. We receive some email that takes FOREVER to open in Word when
forwarded (daily procedure), so we need to be able to easily uncheck the MS
Word to Edit Email Msgs box before forwarding these messages and easily
re-check that box. They are used to having buttons on the toolbar to perform
macros and other tasks, so that's why I need a macro in Outlook. I know how
to create a macro in Word and can fake my way through some VBA, but I don't
know where to start to have an Outlook macro change the mailformat for me.
--
Maureen


"Eric Legault [MVP - Outlook]" wrote:

> Hi Maureen. If you're dealing with these settings at a program level, see my
> post here:
>
> Outlook's Message Format Settings In The Registry:
> http://blogs.officezealot.com/legau...08/03/1324.aspx
>
> For a specific message, you will have to automate clicking the choices under
> the Format menu by using CommandBar and CommandBarButton objects from the
> Office Object Model. However, you have to switch to Plain Text in between.
> So HTML -> Plain Text -> Rich Text -> Plain Text -> HTML. Why do you need to
> do this?
>
> --
> Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.)
> Try Picture Attachments Wizard for Outlook:
> http://www.collaborativeinnovations.ca
> Blog: http://blogs.officezealot.com/legault/
>
>
> "Maureen" wrote:
>
> > I need to create a macro in Outlook 2002 to change the mail format from HTML
> > to rich text and another to change it back to HTML. Can anyone help?
> > --
> > Maureen

  Reply With Quote
Old 15-03-2006, 12:51 AM   #4
=?Utf-8?B?RXJpYyBMZWdhdWx0IFtNVlAgLSBPdXRsb29rXQ==
Guest
 
Posts: n/a
Default RE: need Outlook 2002 macro to change mail format

If you're new to Outlook VBA, this is an excellent resource to help get you
started:

Visual Basic and VBA Coding in Microsoft Outlook:
http://www.outlookcode.com/d/vb.htm

However, what you want to do doesn't really involve using VBA with the
Outlook Object Model, but direct modifications to the registry as I describe
in my blog post referred to in my previous message. To modify the registry,
Google for "VB Registry Class" for plenty of free source code that can help
you set and retrieve registry values. Once that code is in place inside a
VBA module, wire a macro up to a custom button much like you do in Word.

One caveat: changes to values in registry keys that Outlook uses may not be
read until Outlook is restarted. I currently do not know if Outlook's
message format values in the registry behave in the same way.

--
Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"Maureen" wrote:

> I was asked to create a series of documents in Word that includes data pasted
> from the clipboard when the Word macro is run. To satisfy all the
> requirements, I changed the Outlook mail format to HTML using MS Word to Edit
> Email Msgs. We receive some email that takes FOREVER to open in Word when
> forwarded (daily procedure), so we need to be able to easily uncheck the MS
> Word to Edit Email Msgs box before forwarding these messages and easily
> re-check that box. They are used to having buttons on the toolbar to perform
> macros and other tasks, so that's why I need a macro in Outlook. I know how
> to create a macro in Word and can fake my way through some VBA, but I don't
> know where to start to have an Outlook macro change the mailformat for me.
> --
> Maureen
>
>
> "Eric Legault [MVP - Outlook]" wrote:
>
> > Hi Maureen. If you're dealing with these settings at a program level, see my
> > post here:
> >
> > Outlook's Message Format Settings In The Registry:
> > http://blogs.officezealot.com/legau...08/03/1324.aspx
> >
> > For a specific message, you will have to automate clicking the choices under
> > the Format menu by using CommandBar and CommandBarButton objects from the
> > Office Object Model. However, you have to switch to Plain Text in between.
> > So HTML -> Plain Text -> Rich Text -> Plain Text -> HTML. Why do you need to
> > do this?
> >
> > --
> > Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.)
> > Try Picture Attachments Wizard for Outlook:
> > http://www.collaborativeinnovations.ca
> > Blog: http://blogs.officezealot.com/legault/
> >
> >
> > "Maureen" wrote:
> >
> > > I need to create a macro in Outlook 2002 to change the mail format from HTML
> > > to rich text and another to change it back to HTML. Can anyone help?
> > > --
> > > Maureen

  Reply With Quote
Old 15-03-2006, 05:58 AM   #5
Michael Bauer
Guest
 
Posts: n/a
Default Re: need Outlook 2002 macro to change mail format

Am Tue, 14 Mar 2006 10:56:29 -0800 schrieb Eric Legault [MVP - Outlook]:

While with the CommandBar trick you´ll lose all the formattings, in OL 2002
(and up) you could simply switch the Bodyformat property.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.vbOffice.net --


> Hi Maureen. If you're dealing with these settings at a program level, see

my
> post here:
>
> Outlook's Message Format Settings In The Registry:
> http://blogs.officezealot.com/legau...08/03/1324.aspx
>
> For a specific message, you will have to automate clicking the choices

under
> the Format menu by using CommandBar and CommandBarButton objects from the
> Office Object Model. However, you have to switch to Plain Text in

between.
> So HTML -> Plain Text -> Rich Text -> Plain Text -> HTML. Why do you need

to
> do this?

  Reply With Quote
Old 15-03-2006, 06:04 AM   #6
Alan
Guest
 
Posts: n/a
Default Re: need Outlook 2002 macro to change mail format


"Maureen" <Maureen@discussions.microsoft.com> wrote in message
news:6D1F8459-E4AE-4211-AE2E-2F7A5F8AF008@microsoft.com...
>I need to create a macro in Outlook 2002 to change the mail format
>from HTML
> to rich text and another to change it back to HTML. Can anyone
> help?
> --
> Maureen



Hi,

The code below will take you from any format (other than already RTF)
to RTF. You should be able to amend to do what you want.

You'll need to amend the folder names too depending on whether the
files and deleted items are in a PST or not.

HTH,

Alan.

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Sub Convert_To_RTF()

Dim ConvertItem As MailItem
Dim OriginalItem As MailItem
Dim FolderCollection As Folders
Dim AlanMainMailFileFolders As Folders



Set FolderCollection = Application.GetNamespace("MAPI").Folders
Set AlanMainMailFileFolders = FolderCollection("Alan - Main Mail
File").Folders


' Max items found by trial and error to be greater than 238
' Not sure how many it could handle in one go, but I put in 200 to
play it safe
' Probably related to your PC too?

If ActiveExplorer.Selection.Count > 200 Then

MsgBox "Too many items to do them all at once. Please select
fewer items."

Exit Sub

End If


On Error Resume Next


For Each ConvertItem In ActiveExplorer.Selection

' Check if an OlMail item class and not already RTF

If ((ConvertItem.Class = 43) And Not
(ConvertItem.GetInspector.EditorType = olEditorWord)) Then

Set OriginalItem = ConvertItem.Copy
OriginalItem.Move AlanMainMailFileFolders("Deleted Items")

ConvertItem.Body = ConvertItem.Body & " "

ConvertItem.Save

End If

Next


On Error GoTo 0


MsgBox "Finished converting " & ActiveExplorer.Selection.Count & "
MailItems to RTF"

End Sub


+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

--

The views expressed are my own, and not those of my employer or anyone
else associated with me.

My current valid email address is:

6f7chu602@sneakemail.com

This is valid as is. It is not munged, or altered at all.

It will be valid for AT LEAST one month from the date of this post.

If you are trying to contact me after that time,
it MAY still be valid, but may also have been
deactivated due to spam. If so, and you want
to contact me by email, try searching for a
more recent post by me to find my current
email address.

The following is a (probably!) totally unique
and meaningless string of characters that you
can use to find posts by me in a search engine:

ewygchvboocno43vb674b6nq46tvb




  Reply With Quote
Old 15-03-2006, 02:45 PM   #7
=?Utf-8?B?TWF1cmVlbg==?=
Guest
 
Posts: n/a
Default Re: need Outlook 2002 macro to change mail format

Do you mean that when I open a message, there's a way to change the body
format before clicking on forward? I looked through all the toolbars and
didn't find that choice.
--
Maureen


"Michael Bauer" wrote:

> Am Tue, 14 Mar 2006 10:56:29 -0800 schrieb Eric Legault [MVP - Outlook]:
>
> While with the CommandBar trick you´ll lose all the formattings, in OL 2002
> (and up) you could simply switch the Bodyformat property.
>
> --
> Viele Gruesse / Best regards
> Michael Bauer - MVP Outlook
> -- www.vbOffice.net --
>
>
> > Hi Maureen. If you're dealing with these settings at a program level, see

> my
> > post here:
> >
> > Outlook's Message Format Settings In The Registry:
> > http://blogs.officezealot.com/legau...08/03/1324.aspx
> >
> > For a specific message, you will have to automate clicking the choices

> under
> > the Format menu by using CommandBar and CommandBarButton objects from the
> > Office Object Model. However, you have to switch to Plain Text in

> between.
> > So HTML -> Plain Text -> Rich Text -> Plain Text -> HTML. Why do you need

> to
> > do this?

>

  Reply With Quote
Old 15-03-2006, 02:45 PM   #8
=?Utf-8?B?TWF1cmVlbg==?=
Guest
 
Posts: n/a
Default RE: need Outlook 2002 macro to change mail format

Thank you for your help, but I'm trying to NOT make any changes in the
registry if possible. Your suggestions have definitely educated me and
helped me though.
--
Maureen


"Eric Legault [MVP - Outlook]" wrote:

> If you're new to Outlook VBA, this is an excellent resource to help get you
> started:
>
> Visual Basic and VBA Coding in Microsoft Outlook:
> http://www.outlookcode.com/d/vb.htm
>
> However, what you want to do doesn't really involve using VBA with the
> Outlook Object Model, but direct modifications to the registry as I describe
> in my blog post referred to in my previous message. To modify the registry,
> Google for "VB Registry Class" for plenty of free source code that can help
> you set and retrieve registry values. Once that code is in place inside a
> VBA module, wire a macro up to a custom button much like you do in Word.
>
> One caveat: changes to values in registry keys that Outlook uses may not be
> read until Outlook is restarted. I currently do not know if Outlook's
> message format values in the registry behave in the same way.
>
> --
> Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.)
> Try Picture Attachments Wizard for Outlook:
> http://www.collaborativeinnovations.ca
> Blog: http://blogs.officezealot.com/legault/
>
>
> "Maureen" wrote:
>
> > I was asked to create a series of documents in Word that includes data pasted
> > from the clipboard when the Word macro is run. To satisfy all the
> > requirements, I changed the Outlook mail format to HTML using MS Word to Edit
> > Email Msgs. We receive some email that takes FOREVER to open in Word when
> > forwarded (daily procedure), so we need to be able to easily uncheck the MS
> > Word to Edit Email Msgs box before forwarding these messages and easily
> > re-check that box. They are used to having buttons on the toolbar to perform
> > macros and other tasks, so that's why I need a macro in Outlook. I know how
> > to create a macro in Word and can fake my way through some VBA, but I don't
> > know where to start to have an Outlook macro change the mailformat for me.
> > --
> > Maureen
> >
> >
> > "Eric Legault [MVP - Outlook]" wrote:
> >
> > > Hi Maureen. If you're dealing with these settings at a program level, see my
> > > post here:
> > >
> > > Outlook's Message Format Settings In The Registry:
> > > http://blogs.officezealot.com/legau...08/03/1324.aspx
> > >
> > > For a specific message, you will have to automate clicking the choices under
> > > the Format menu by using CommandBar and CommandBarButton objects from the
> > > Office Object Model. However, you have to switch to Plain Text in between.
> > > So HTML -> Plain Text -> Rich Text -> Plain Text -> HTML. Why do you need to
> > > do this?
> > >
> > > --
> > > Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.)
> > > Try Picture Attachments Wizard for Outlook:
> > > http://www.collaborativeinnovations.ca
> > > Blog: http://blogs.officezealot.com/legault/
> > >
> > >
> > > "Maureen" wrote:
> > >
> > > > I need to create a macro in Outlook 2002 to change the mail format from HTML
> > > > to rich text and another to change it back to HTML. Can anyone help?
> > > > --
> > > > Maureen

  Reply With Quote
Old 15-03-2006, 02:47 PM   #9
=?Utf-8?B?TWF1cmVlbg==?=
Guest
 
Posts: n/a
Default Re: need Outlook 2002 macro to change mail format

Thank you!
--
Maureen


"Alan" wrote:

>
> "Maureen" <Maureen@discussions.microsoft.com> wrote in message
> news:6D1F8459-E4AE-4211-AE2E-2F7A5F8AF008@microsoft.com...
> >I need to create a macro in Outlook 2002 to change the mail format
> >from HTML
> > to rich text and another to change it back to HTML. Can anyone
> > help?
> > --
> > Maureen

>
>
> Hi,
>
> The code below will take you from any format (other than already RTF)
> to RTF. You should be able to amend to do what you want.
>
> You'll need to amend the folder names too depending on whether the
> files and deleted items are in a PST or not.
>
> HTH,
>
> Alan.
>
> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
>
> Sub Convert_To_RTF()
>
> Dim ConvertItem As MailItem
> Dim OriginalItem As MailItem
> Dim FolderCollection As Folders
> Dim AlanMainMailFileFolders As Folders
>
>
>
> Set FolderCollection = Application.GetNamespace("MAPI").Folders
> Set AlanMainMailFileFolders = FolderCollection("Alan - Main Mail
> File").Folders
>
>
> ' Max items found by trial and error to be greater than 238
> ' Not sure how many it could handle in one go, but I put in 200 to
> play it safe
> ' Probably related to your PC too?
>
> If ActiveExplorer.Selection.Count > 200 Then
>
> MsgBox "Too many items to do them all at once. Please select
> fewer items."
>
> Exit Sub
>
> End If
>
>
> On Error Resume Next
>
>
> For Each ConvertItem In ActiveExplorer.Selection
>
> ' Check if an OlMail item class and not already RTF
>
> If ((ConvertItem.Class = 43) And Not
> (ConvertItem.GetInspector.EditorType = olEditorWord)) Then
>
> Set OriginalItem = ConvertItem.Copy
> OriginalItem.Move AlanMainMailFileFolders("Deleted Items")
>
> ConvertItem.Body = ConvertItem.Body & " "
>
> ConvertItem.Save
>
> End If
>
> Next
>
>
> On Error GoTo 0
>
>
> MsgBox "Finished converting " & ActiveExplorer.Selection.Count & "
> MailItems to RTF"
>
> End Sub
>
>
> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
>
> --
>
> The views expressed are my own, and not those of my employer or anyone
> else associated with me.
>
> My current valid email address is:
>
> 6f7chu602@sneakemail.com
>
> This is valid as is. It is not munged, or altered at all.
>
> It will be valid for AT LEAST one month from the date of this post.
>
> If you are trying to contact me after that time,
> it MAY still be valid, but may also have been
> deactivated due to spam. If so, and you want
> to contact me by email, try searching for a
> more recent post by me to find my current
> email address.
>
> The following is a (probably!) totally unique
> and meaningless string of characters that you
> can use to find posts by me in a search engine:
>
> ewygchvboocno43vb674b6nq46tvb
>
>
>
>
>

  Reply With Quote
Old 15-03-2006, 04:34 PM   #10
=?Utf-8?B?RXJpYyBMZWdhdWx0IFtNVlAgLSBPdXRsb29rXQ==
Guest
 
Posts: n/a
Default Re: need Outlook 2002 macro to change mail format

Certainly; this option is already there and if you didn't know about it, you
don't need any code.

With an open message, select the format you want from the Format menu. Note
that Rich Text will not be listed if the current format is HTML, and vice
versa. You need to switch to Plain Text when converting between Rich Text
and HTML back and forth.

--
Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"Maureen" wrote:

> Do you mean that when I open a message, there's a way to change the body
> format before clicking on forward? I looked through all the toolbars and
> didn't find that choice.
> --
> Maureen
>
>
> "Michael Bauer" wrote:
>
> > Am Tue, 14 Mar 2006 10:56:29 -0800 schrieb Eric Legault [MVP - Outlook]:
> >
> > While with the CommandBar trick you´ll lose all the formattings, in OL 2002
> > (and up) you could simply switch the Bodyformat property.
> >
> > --
> > Viele Gruesse / Best regards
> > Michael Bauer - MVP Outlook
> > -- www.vbOffice.net --
> >
> >
> > > Hi Maureen. If you're dealing with these settings at a program level, see

> > my
> > > post here:
> > >
> > > Outlook's Message Format Settings In The Registry:
> > > http://blogs.officezealot.com/legau...08/03/1324.aspx
> > >
> > > For a specific message, you will have to automate clicking the choices

> > under
> > > the Format menu by using CommandBar and CommandBarButton objects from the
> > > Office Object Model. However, you have to switch to Plain Text in

> > between.
> > > So HTML -> Plain Text -> Rich Text -> Plain Text -> HTML. Why do you need

> > to
> > > do this?

> >

  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

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