0

I am completely clueless about VBA for outlook. I was hoping that I could record macros, but I see that its not possible.

So the issue I am having is that I receive close to 100 emails daily that arrive in plain text, and I always need to convert to HTML so that I can select a Quick Parts, then send the email.

Can this be automated with VBA?

braX
  • 11,506
  • 5
  • 20
  • 33
robert
  • 1
  • 1
  • Possible duplicate of [How can I convert a selection of emails from RichText to HTML Format?](https://stackoverflow.com/questions/48708291/how-can-i-convert-a-selection-of-emails-from-richtext-to-html-format) – niton Nov 12 '19 at 16:32

1 Answers1

0

The MailItem.BodyFormat property allows setting an OlBodyFormat constant indicating the format of the body text. For example:

Sub CreateHTMLMail() 

 'Creates a new email item and modifies its properties. 

 Dim objMail As MailItem 



 'Create mail item 

 Set objMail = Application.CreateItem(olMailItem) 

 With objMail 

 'Set body format to HTML 

 .BodyFormat = olFormatHTML 

 .HTMLBody = "<HTML><H2>The body of this message will appear in HTML.</H2><BODY>Type the message text here. </BODY></HTML>" 

 .Display 

 End With 

End Sub

To handle incoming emails you may use the NewMailEx event of the Application class. The NewMailEx event fires when a new message arrives in the Inbox and before client rule processing occurs. You can use the Entry ID returned in the EntryIDCollection array to call the NameSpace.GetItemFromID method and process the item.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45