Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
h_demarco
Contributor III
Contributor III

VB Macro to create e-mail from HTML file

Dear helpers,

I have a macro to create e-mail and send few charts to company stakeholders. My intention is to use HTML file emailrep.html as a default for body. This HTML file has more than 400 lines, so it is hard to convert it to a string using "& _" in the end of each line.

Pasting HTML code into Qlikview macro creates syntax error.

Set MyOlApp = CreateObject("Outlook.Application")

Set myItem = MyOlApp.CreateItem(olMailItem)

htmlfile = "Qlikview\emailrep.html"

With myItem

    .To = Email.Item(i).Text

    .BodyFormat = 2

    .Subject = "Sales Report - " & Field.Item(i).Text

    .HTMLBody = htmlfile

    .Attachments.Add ("Report.pdf")

    .Display

End With

Does anyone know how to get HTML file and use as e-mail body with this circumstances?

The use of Outlook is not mandatory. Just developed because it is easier for me.

1 Solution

Accepted Solutions
marcus_sommer

I think you need to pass the html as string and not as a reference to a file (and it must be an absolute path and not a relative one) - have a look on these (similar) example: Re: Exportar varias tablas a un archivo html.

- Marcus

View solution in original post

2 Replies
marcus_sommer

I think you need to pass the html as string and not as a reference to a file (and it must be an absolute path and not a relative one) - have a look on these (similar) example: Re: Exportar varias tablas a un archivo html.

- Marcus

h_demarco
Contributor III
Contributor III
Author

Marcus,

I changed from Outlook to CDO object. Using CreateMHTMLBody method did exactly what I was looking for.

So, thank you much. I own you a beer.

Henrique