LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to send HTML as message body using SMTP

I need to send HTML formatted emails. I used the Report Generation Toolkit to build my HTML document and make sure I had all of the formatting right. Then I modified the Save Report To File.vi to also give me the HTML text string on an output connector and I wire this string to the message input on the SMTP Email Send Message.vi.

I receive the email OK, but all I see is the HTML code in the message body. What can I do to make sure that the email displays the message correctly.

I use Outlook and I know it will receive and display HTML emails, I get them all the time.

I would appreciate any help.
0 Kudos
Message 1 of 4
(7,860 Views)
Hi,
your problem is that "SMTP Email Send Message.vi" send message as MINE content-type "text/plain". You must change this MINE content-type to "text/html" type.

You can change this value permanent in "SMTP Email MIME Text Content-Type.vi" or you can creat new control "MINE content-type" and take it out to "SMTP Email Send Message.vi". [after care for char '\n' on the end of new control "MINE content-type" string - you must delete it]

Good luck.

JCC
Message 2 of 4
(7,860 Views)
JCC,

Thanks for the help. That worked perfectly.

One more question. Can I send embedded jpg or gif images in an HTML formatted email?

Thanks again,

dgw
0 Kudos
Message 3 of 4
(7,860 Views)
Hi Dgw,
it is similar. You must change message MINE content-type to "text/html" type. Because everyone document in email protocol have set MINE content-type. It is inforamtion for email servers and for email cients (Thunderbird, Outlook and etc.)

For sendning mail with attachments you must use and modified "SMTP Send Multiple Attachments.vi" - if you can do backup of this VI and subVIs. Open Diagram of "SMTP Send Multiple Attachments.vi" after "SMTP Send Multiple
Attachments Message.vi" and ther is VI "MIME Send Data Attachment.vi" - have control "MIME content-type" but code from NI don't use it.

And like as my previous message, create new string control "MINE content-type" and take out this control to "main" Email VI.

And embedd
ed file you set up in control-cluster "attachments". I don't test it, but I mind thet must working 🙂

Have nice day

JCC
0 Kudos
Message 4 of 4
(7,860 Views)