Link to home
Start Free TrialLog in
Avatar of crownhelpdesk
crownhelpdesk

asked on

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.
Avatar of David Lee
David Lee
Flag of United States of America image

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!
Avatar of crownhelpdesk
crownhelpdesk

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of David Lee
David Lee
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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?
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?
Hi, crownhelpdesk.

Any progress?
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,
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.