This content is not available in your preferred language.

The content is shown in another available language. Your browser may include features that can help translate the text.

Send an HTML Formatted E-mail in LabVIEW Instead of Plain Text

Updated Oct 27, 2023

Reported In

Software

  • LabVIEW

Issue Details

I am trying to write HTML code into an email and send it using LabVIEW's SMTP Email VIs. I want the receiver to get the formatted message and not just the HTML code. How can I send an HTML formatted e-mail in LabVIEW?
 

Solution

LabVIEW 2013 and Later
LabVIEW 2013 and later include SMTP Email VIs on the SMTP Email palette. The newer SMTP Email palette includes the Set Message VI. Use the Text & HTML instance of this VI to send an HTML-formatted message.

LabVIEW 2012 and Earlier
You will have to make some slight modifications to the Email VIs to send an HTML formatted email because, by default, LabVIEW sends plain text. For a server to use HTML to read an e-mail, the header must specify that this particular email is formatted using HTML. 

This header is created by a subVI two levels down into the SMTP Email Send Message VI. To send formatted emails, you need to find the VI that writes the header and change the input to this VI from "text/plain" to "text/html". In order to find and change the input to the header VI, you should follow these steps:
  1. Begin with SMTP Email Send Message.vi
  2. Double-click to open and look at the block diagram.
  3. Open the VI called SMTP Email Send Message Charset.vi (located on the right)
  4. Next, open the VI called SMTP Email Send Text Message.vi (located in the middle)
  5. The SMTP Email MIME Send Header.vi is where you need to specify usage of HTML.  The input to this header VI is written by SMTP Email MIME Text Content-Type.vi. Open SMTP Email MIME Text Content-Type.vi
  6. Inside you will see the following string, as also displayed below: text/plain;%s charset="%s
  1. Change the word plain to html.
  2. Save the VI, but keep a copy of the old VI so that you can revert to the shipped version if needed.

Additional Information

You can use the SMTP Email VIs to send email, including attached data and files. LabVIEW sends the email using the Simple Mail Transfer Protocol (SMTP). For added security, you can use Transport Layer Security (TLS) to communicate with the SMTP server. You also can specify authentication credentials for the SMTP client.

The SMTP Email palette includes the Send Email Express VI. You can use the Send Email Express VI to send emails quickly from LabVIEW to a list of recipients you specify. However, if you want to configure headers, set TLS settings, or include an attachment, you must use the standard SMTP Email VIs to configure and send an email with more advanced settings.

You can find Send Email using SMTP Client.vi example at Help»Find Examples»Networking»Internet & Web