View Single Post
  #4  
Old July 6th 09, 04:17 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Switch Mail format

You will obviously need a reference to Outlook in your VBA project. Then in
a code module something like this:

' Module level code
Dim WithEvents colInsp As Outlook.Inspectors
Dim WithEvents oInsp As Outlook.Inspector
Dim oApp As Outlook.Application
Dim oNS As Outlook.NameSpace

Dim blnFirstActivate As Boolean

Sub SetThingsUp()
Set oApp = CreateObject("Outlook.Application")
Set oNS = oApp.GetNameSpace("MAPI")
oNS.Logon "", "", False, False
Set colInsp = oApp.Inspectors
End Sub

Sub colInsp_NewInspector(Inspector As Inspector)
If (Inspector.CurrentItem.Class = olMail) Then
blnFirstActivate = False
Set oInsp = Inspector
End If
End Sub

Sub oInsp.Activate()
If (Not blnFirstActivate) Then
blnFirstActivate = True

If (oInsp.CurrentItem.BodyFormat = olFormatHTML) Then
oInsp.CurrentItem.BodyFormat = olFormatPlain
End If
End If
End Sub

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Mats Samson" wrote in message
...
Thanks Ken,
but I'm fairly unfamiliar with Outlook programming, usually I work with
Excel and I know there are special arguments etc that have to be set
before
Outlook cooperates with you, so..... I would appreciate if you can give me
a
code example?
Cheers
Mats


Ads