Adding a VBA script

  • Thread starter Thread starter Grant
  • Start date Start date
G

Grant

Hello List:

I have a slight problem here which I would very much
appreciate help with. Owing to certain accessibility
software that I use to read Email messages, it is easier
for me to read HTML messages than plain text messages,
even if they are the exact same font, color, etc.
I have a VBA script that will supposedly convert all
incoming plain text messages into HTML format. I have
consulted Microsoft who assure me that this can be done
with VB script.
I would like to request that somebody read my code, tell
me whether or not they think it will work and tell me
exactly (step by step please) how to add it to the This
Session module and make Outlook recognize it. Here's the
code:

Private WithEvents olInboxItems As Items

Private Sub Application_Startup()

Dim objNS As NameSpace

Set objNS = Application.GetNamespace("MAPI")

' instantiate objects declared WithEvents

Set olInboxItems = objNS.GetDefaultFolder
(olFolderInbox).Items

Set objNS = Nothing

End Sub

Private Sub Application_Quit()

' disassociate global objects declared WithEvents

Set olInboxItems = Nothing

End Sub

Private Sub olInboxItems_ItemAdd(ByVal Item As Object)

On Error Resume Next

If Item.HTMLBody <> vbNullString Then

Item.HTMLBody = Item.Body

Item.Save

End If

Set Item = Nothing

End Sub

Thanks so much,

Grant
 
Back
Top