Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 666
  • Last Modified:

Convert all incoming messages to HTML format

I have created a signature file that needs to be attached to all emails. Since some emails that we receive are in Plain text or RTF when users reply the signature will not be added. I need to have it automated since many of the users are unaware how to change the format. I used the following VBA code to change all the messages to HTML in Outlook 2003:

=================================
Sub ConvertPlainToHtml(MyMail As MailItem)
    Dim strID As String
    Dim olNS As Outlook.NameSpace
    Dim olMail As Outlook.MailItem
    strID = MyMail.EntryID
    Set olNS = Application.GetNamespace("MAPI")
    Set olMail = olNS.GetItemFromID(strID)
    olMail.BodyFormat = olFormatHTML
    olMail.Save
    Set olMail = Nothing
    Set olNS = Nothing
End Sub
=================================

Is there code that I can put in Outlook 2000 VBA that will do the same thing? I know very little in VBA for Outlook, could
someone walk me through what I need to do.
0
crownhelpdesk
Asked:
crownhelpdesk
  • 5
  • 3
1 Solution
 
David LeeCommented:
Hi crownhelpdesk,

It shouldn't matter what format the message is in.  When you create a signature Outlook makes three versions of it, one for HTML, one for palin text, and one for Rich-text.  You can verify this by looking in the folder C:\Documents and Settings\<username>\Application Data\Microsoft\Signatures.  You should see a .htm, .txt. and .rtf version for each signature.

That aside, the code you posted looks to me like it should work finr in Outlook 2000.  It's been awhile since I used 2000, but the things that changed between versions shouldn't affect this working.  Have you tried this code in 2000?

Cheers!
0
 
crownhelpdeskAuthor Commented:
Sorry I should have included that the signature file was created by our marketing department and it is a .jpeg, I did try the same code in
Outlook 2000 but nothing happened. I dont know if I am calling the function right.  I copied over from 2003 that exact function and it doesnt work.
Nothing happens.
0
 
David LeeCommented:
The code should work, but something, a new message arriving for example, has to trigger it.  I assumed you already had that part and was just questioning whether the code to convert will work.  Here's a version I wrote sometime ago.  Follow these instructions to use it.

1.  Start Outlook
2.  Click Tools->Macro->Visual Basic Editor
3.  If not already expanded, expand Microsoft Office Outlook Objects and click on ThisOutlookSession
4.  Copy the code below and paste it into the right-hand pane of the VB Editor window
5.  Click the diskette icon on the toolbar to save the changes
6.  Close the VB Editor
7.  Click Tools->Macro->Security
8.  Set the Security Level to Medium.  
9.  Close Outlook
10. Start Outlook


'CODE BEGINS HERE
Private WithEvents olkInboxItems As Outlook.Items

Private Sub olkInboxItems_ItemAdd(ByVal Item As Object)
    If Item.Class = olMail Then
        If Item.BodyFormat <> olFormatHTML Then
            Item.BodyFormat = olFormatHTML
            Item.Save
        End If
    End If
End Sub

Private Sub Application_Quit()
    Set olkInboxItems = Nothing
End Sub

Private Sub Application_Startup()
    Set olkInboxItems = Session.GetDefaultFolder(olFolderInbox).Items
End Sub
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
crownhelpdeskAuthor Commented:
Alright I followed your instructions, when I tested it with a plain text email.
its displayed a run-time error saying the object was invalid. Any other ideas?
0
 
David LeeCommented:
I tested the code before posting and tested it again just now.  It works perfectly.  Of course I'm using Outlook 2003 not 2000.  Did you follow the instructions exactly?  If you open the code editor does the code appear in the module ThisOutlookSession?  What line of code did it halt on?
0
 
David LeeCommented:
Hi, crownhelpdesk.

Any progress?
0
 
crownhelpdeskAuthor Commented:
Sorry, havent responded I tried what you suggested but for some reason it will not convert. I was able to get it to work in 2003, but not 2000.
I have been so busy that I havent been able to spend any time on it. Thanks for the help,
0
 
David LeeCommented:
No problem.  Glad I was able to help some.  Sorry I don't have 2000 anymore so I could help figure out what's going on there.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now