VBA – send an e-mail from Excel, using MS Outlook and HTML

With this article I will simply present you with a solution, combining HTML and VBA, exporting a graph from excel to MS Outlook e-mail.

The HTML part is a little complicated and not very flexible, but anyhow – it is just an example that HTML can be incorporated in VBA.

So here comes the code:

It is not my best piece of code, with a lot of hard coding in it, but the idea is that it should be just an example.

Here are a couple of things, you should do before running this code:

1. Add the MS Outlook library to MS Excel. Simply open the VB Editor, click on Tools, then References.

2. Then select “Microsoft Outlook 14.0. Object Library (or something that sounds similar, if you are not using Office 2010)


3. Open MS Outlook and leave it opened.

4. Create an empty Excel file and simply save it somewhere. (it should be saved, the macro does not work otherwise)

5. Create some simple chart on the first sheet and do not change the name of the first sheet.

Then the macro works!

If you are tired/lazy/unwilling to do the five last steps, you may download a working version of this tool from here.

That is it! Enjoy the file and do not become spammers 🙂

Tagged with: