If you are accustomed to viewing emails in a specific format, you can use the means introduced in this article. It will teach you how to use VBA to automatically change the body format of incoming emails.
As we know, if you reply or format an email, the replying or forwarding email will automatically use the body format of the original email. Perhaps its format is not suitable for your case. For instance, if the original email is in Plain Text format, in your replying email, by default, you will be unable to insert picture, hyperlink or table, etc. Of course you can manually change the body format to HTML. However, why not directly use VBA to automatically change the body format of all incoming emails? By this means, you will never need to change the format manually. Now, in the followings, we will expose the elaborate steps and VBA codes to you.
Auto Change the Body Format of Incoming Emails
- At the very outset, start your Outlook program.
- Then in the main Outlook window, press “Alt + F11” key buttons.
- Subsequently, you will get into Outlook VBA editor window successfully.
- Next you need to double click on the “ThisOutlookSession” project on the left side.
- Then you should copy and paste the following VBA codes into it.
Public WithEvents objIncomingItems As Outlook.Items Private Sub Application_Startup() Set objIncomingItems = Outlook.Application.Session.GetDefaultFolder(olFolderInbox).Items End Sub Private Sub objIncomingItems_ItemAdd(ByVal objItem As Object) Dim objMail As Outlook.MailItem If TypeOf objItem Is MailItem Then Set objMail = objItem 'Change all the body format of incoming emails to HTML 'You can change olFormatHTML to olFormatPlain or olFormatRichText as per your needs If objMail.BodyFormat <> olFormatHTML Then objMail.BodyFormat = olFormatHTML objMail.Save End If End If End Sub
- After that, you should sign this code.
- Firstly, use Digital Certificates for VBA Projects to create a certificate.
- Then in the current “ThisOutlookSession” project, click “Tools” > “Digital Signature” and next follow the onscreen instructions to assign the new certificate to this VBA project.
- Later you should change your Outlook macro settings to permit the digitally signed macros.
- Finally you can restart your Outlook to activate the new VBA project.
- From now on, all the incoming emails will be auto changed to the predefined format as per your own VBA code, such as HTML format in my code.
Avoid Desperate Outlook PST Issues
Since Outlook is vulnerable to various factors, you have to try your best to protect your Outlook PST file. Making sufficient precautions is of great importance, such as backing up your Outlook PST data on a regular basis and keeping a potent PST fix tool handy, like DataNumen Outlook Repair, and so on.
Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including SQL Server fix and outlook repair software products. For more information visit www.datanumen.com