LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

I need to put a "Send Email" button in a LabWindows/CVI dialog.

When the user encounters an error, I want to give him the capability to click on a "Send Email" button which will start whatever the user's default email application is, and perhaps use the error message as the body of the email.

You can get an idea of what I want, if you think about what a web-browser (such as IE, Netscape, etc) does when you click on a "mailto:xxxxx" hyperlink.

We don't need to do the full activeX stuff: the user can fiddle around with his email application. I *could* use LaunchExecutable() or even system(), but that would not tell MSWindows to launch whatever the user's default emailer application is.
0 Kudos
Message 1 of 2
(2,678 Views)
You can do this using the ShellExecute() function in the Windows SDK.

e.g.:


#include
#include

...

int errorCode = (int)ShellExecute(NULL,NULL,"mailto:sample@sample.com",NULL,NULL,0);



if (32>=errorCode)
{
// didn't work - error processing here
}


You will have to include the SDK import library file SHELL32.LIB in your project.

You can also use the CVI LaunchExecutable function, but it's not as nice and is OS dependent (I think).

In win9x/Me:
LaunchExecutable("start.exe mailto:sample@sample.com");

In NT/2000/XP:
LaunchExecutable("cmd.exe /c start mailto:sample@sample.com");

('start' is an external command in 9x/Me but a cmd.exe builtin in NT/2000/XP)

HTH,
HAND,
Martin.
--
Martin
Certified CVI Developer
0 Kudos
Message 2 of 2
(2,678 Views)