Example Code

Use LabVIEW to Send Email with Microsoft Outlook

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

    Other

  • ActiveX

Code and Documents

Attachment

Description

This example uses Microsoft Outlook ActiveX objects to create a new message and then send that message using the Microsoft Outlook engine. The VI was developed and testing using Microsoft Outlook 2002. 

Note: This example has been tested with LabVIEW 2021 and Outlook 365 with no issues.

How to Use

  1. Enter data into the To, Subject, and message controls on the front panel.
    • The other controls, CC and BCC, are optional.
    • When using multiple email addresses separate addresses with a semicolon.
  2. Run the VI to send an email to the specified email address.
    • If you have the E-mail security update installed with some Microsoft Outlook, you may be prompted to authorize the automated email and override the security warning. Click OK in the message box to send the email. For truly automated messaging, you can override this warning message programmatically using third party software.

Related Links

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
HosseinBakhtiari
Member
Member
on

Hi,

 

I'm facing a problem using the SubVI send_outlook_mail_active.vi. The problem is that I get the below broken wire error if I use the SubVI in a project that also includes cRIO. It worked and still works fine if I use it in a VI with simulated modules. However I would like to use it with cRIO, the idea is that it will send me an email if the values I'm measuring are not not within the limits. 

 

I wander if anyone has faced a similar problem or knows how I could resolve my problem? I have never used the blocks used in the SubVI, so I'm bit lost.

 

HosseinBakhtiari_0-1660910089269.png

 

Additional information about my systems

- LabView 2021 - 32 bit

- LabVIEW FPGA Module 2021

- LabVIEW Real-Time Module 2021

- NI CompactRIO Drivers 21.0

- NI DAQmx 21.0

- cRIO-9056

 

Thank you in advance!

Kind regards,

Hossein Bakhtiari

JohnatanBravo
Member
Member
on

This is great. Happy to report it still works in 2024!

 

Any idea why the Outlook_.MailItem doesn't have a 'Message-ID' element?

Is there a way to set the 'Message-ID' using this Outlook class?