Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
1 ratings:
 4 out of 5     Rate this Document

Using SMTP with from .net In LabVIEW

Primary Software: LabVIEW Development Systems>>LabVIEW Professional Development System
Primary Software Version: 1.0
Primary Software Fixed Version: N/A
Secondary Software: N/A

Problem:
I found an example for sending emails through a .net Object how can I translate this example into LabVIEW? And how can I embed images in a HTML body of a mail with this?

Solution:
The System.Net.Mail namespace contains classes used to send electronic mail to a Simple Mail Transfer Protocol (SMTP) server for delivery.

The MailMessage class represents the content of a mail message. The SmtpClient class transmits email to the SMTP host that you designate for mail delivery. You can create mail attachments using the Attachment class.

 For sending a message the 3 basic Objects that are required is the

System.Net.Mail   SMTPClient, in here you define the address and the port of the SMTP Server you will connect to.

System.Net.Mail   MailMessage, here you define the From: To: Subject and Body.

System.Net  Network Credentials. Here you define the Username and Password if required.

To create any of the above Objects insert a .net  constructor node, and browse to the specific class.

You can find an example of this classes implemented in the SMTPSimple in the attachments sections.

For creating more advance emails you can use objects like Attachments or Alternate Views. For example to create a HTML mail with images attached you have to create an Alternative View and include linked resource. In the HTML code you have to make reference to this linked resource directly. When working with Alternative Views and linked Resources its important to specify the Content Type so it can be identified correctly in the email, for example if the Alternative View is html specify the content type as text/HTML. An example of this ca be seen in the attached VI STMP.vi
msdn.microsoft.com/en-us/library/system.net.mail.attachment.aspx


Related Links:
MSDN: System.Net.Mail Namespace

Sending HTML Mail with Embedded Image in .NET

Attachments:


SMTP.viSMTPSimple.vi


Report Date: 05/23/2008
Last Updated: 06/26/2008
Document ID: 4LM9FQYN

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit