To download NI software, including the products shown below, visit ni.com/downloads.
Due to the hardening of the security policy on the net, some of former facilities of the CVI Internet library don't work as expected any more. Actually most of the SMTP servers require that the sender owns an account and moreover, require an SSL protocol. In turn, the sender must provide the correct TCP IP PORT and, unfortunately, this last feature is not available in the standard InetSendMail which only allows to get the server, using the standard PORT 25. To overcome this difficulty, this article suggests to lies upon the Powershell abilities.
Build a function named 'PS_SendMail' which:
The critical and indispensable parameters, such as the smtp server address, the smtp port, the smtp user and his password can remain hidden in the code or put in a configuration file.
The function PS_SendMail provided in the C source in attachment of this article is really short and simple, doesn't need any extra library and launches the PowerShell thanks to a call to the well-known function system(). Of course, the syntax of Powershell has to be known.
Description-Separate-2
static int PS_SendMail(char *from, char *to, char *subject, char *message) ;
How-Separate-2
Additional-Separate-2
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.