3

I'm looking to open a default email program after a click on a hyperlink control in my app that links to an email address. For that I do the following:

//LPCTSTR addr = L"mailto:[email protected]";
ShellExecute(hParentWnd, _T("open"), addr, NULL, NULL, SW_SHOWNORMAL);

The approach above usually works by bringing up Outlook or Live Mail new email window with that address filled out in the "To:" field.

But when I have Google Chrome as my default web browser all I get is a blank Chrome browser window that simply shows my home page and nothing else.

So what am I doing wrong here?

0

1 Answer 1

0

Change _T("open") to NULL. Not all apps use "open" as their default verb. NULL forces the actual default to be used.

BTW, you should be using TEXT() instead of _T() when using TCHAR literals with the Win32 API. _T() is meant for use with the C runtime library instead.

2
  • Thanks. Just tried it and it did the exact same thing -- got just a blank home page.
    – c00000fd
    Commented Aug 7, 2014 at 18:19
  • 1
    Then the problem is on Chrome's side, not your app. Maybe it did not register itself with the mailto URL correctly, so it is not detecting the email address. Either way, the problem is not on your end. Commented Aug 7, 2014 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.