0

Is there an even easier (or maybe a little more user-friendly) way to inject a few lines of HTML source code into an Outlook email, than using a macro like shown over there:

Edit the HTML source code while composing a message in Outlook

Outlook HTML source code window of the above macro: HTML source code window of the above macro

Edit 1: Here are some more links on this. It seems that there is no easier way around to be found on the web.

https://www.outlook-apps.com/insert-html-to-outlook-emails https://www.howto-outlook.com/howto/edit-html-source-code-email.htm#quickinstall https://www.werockyourweb.com/community/edit-source-in-outlook-emails/#comment-18745

The code from the last link (see below) is pretty neat. It switches between HTML source and WYSIWYG inside the Outlook message window itself. However, there seem to be problems when switching back to WYSIWYG and Outlook obviously interpreting some of the code as mail text (or something).

May 23, 2008 9:07 am The Other Way

Use these macros to switch the current email between source view and HTML view.

The first will take a HTML message and convert it into a text message, retaining the tags.

Once you’ve edited it and are ready to send, the 2nd one will convert the text message back to HTML.

Evil Overlord

Sub HTML2Text()
Dim objApp As Application
Dim objItem As MailItem
Dim strBody As String
Set objApp = CreateObject("Outlook.Application")
Set objItem = objApp.ActiveInspector.CurrentItem
If (objItem.BodyFormat = olFormatHTML) Then
strBody = objItem.HTMLBody
objItem.HTMLBody = ""
objItem.Body = strBody
objItem.BodyFormat = olFormatPlain
End If
End Sub

Sub Text2HTML()
Dim objApp As Application
Dim objItem As MailItem
Dim strBody As String
Set objApp = CreateObject("Outlook.Application")
Set objItem = objApp.ActiveInspector.CurrentItem
If (objItem.BodyFormat = olFormatPlain) Then
strBody = objItem.Body
objItem.Body = ""
objItem.HTMLBody = strBody
objItem.BodyFormat = olFormatHTML
End If
End Sub
1
  • 1
    You could take the time to learn a little VBA. That macro you point to already shows you how to do all of the "hard part". Instead of putting all of the source text into an edit box, you would simply operate on it like a string and save it using the part of the code that has either "ApplySend" or "Apply". Commented Oct 12, 2022 at 13:41

1 Answer 1

0

Here is a surprisingly straightforward approach:

I wrote my code in notepad++, viewed it in Chrome, and then copied it into my email. Worked beautifully!

I modified this and use BlueGriffon instead to edit the source code of any part of an Outlook email draft. This has the advantage that you can copy the WYSIWYG part in both directions from and to Outlook. Plus, it's a portable program.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .