Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mailto: openExternal does not work on Windows. #1083

Closed
marksalvin opened this issue Feb 2, 2015 · 12 comments
Closed

Mailto: openExternal does not work on Windows. #1083

marksalvin opened this issue Feb 2, 2015 · 12 comments

Comments

@marksalvin
Copy link

I've been trying to use openExternal to open the mail application from within my atom-shell app (with an email passed in), however it's not working on Windows (it's working fine on Mac). Using latest release (v0.21.0, non-symbols version).

Using:

require("shell").openExternal("http://www.google.com") - works.
require("shell").openExternal("mailto:test@test.com") - DOESN'T work. Nothing happens. No error is thrown either in WebInspector console.

@lincleejun
Copy link

If you doesn't install any mail client on your system, this calling will return nothing, but if you install one it works correctly.

in OpenExternal implementation.
when system doesn't have any Mail client, calling ShellExecuteA will got SE_ERR_NOASSOC error.
but if I uninstall got SE_ERR_ACCESSDENIED error code(not restart computer).

maybe should change the API signature, give some response to caller.

@bwin
Copy link
Contributor

bwin commented Feb 12, 2015

With 0.21.2 on Win7 it opens Thundebird without problems.
I'm not going to uninstall my mail-client, but I think it's as lincleejun says: There is no return value, so you don't know if it worked or not.
The title should be changed to "openExternal doesn't tell if there's no mail client" or something...

@marksalvin
Copy link
Author

Did not mean to close this issue. So I can confirm that with the latest version I'm still having issues. I have outlook installed on my system, and mailto: links within the web browser open outlook just fine, it's only from within atom that nothing happens. I installed thunderbird, and the openExternal worked just once but has not worked again since, bizarrely.

So I wouldn't say that it's just a return value issue.

marksalvin pushed a commit to marksalvin/atom-shell that referenced this issue Mar 15, 2015
@zcbenz
Copy link
Contributor

zcbenz commented Oct 30, 2015

This only seems to affect one machine and I didn't see any other report, no one else is able to reproduce this too, so I'm blaming it to Windows.

@zcbenz zcbenz closed this as completed Oct 30, 2015
@bradstewart
Copy link

I'm having the problem exactly as described by @marksalvin on 0.36.2 on all Windows 7 machines I've tested. The machines did have a mail client (tried both Outlook and Thunderbird) installed and registered as the default for the Url:MAILTO scheme.

@Ivshti
Copy link
Contributor

Ivshti commented Feb 24, 2016

Windows is to blame for this, definitely, but has anyone found a workaround? @bradstewart @markisadesignerd

@marksalvin
Copy link
Author

Hi guys.

So originally, my workaround was to modify the openExternal function on Windows:

  if (url.spec().substr(0, 7) == "mailto:" ||
        url.spec().substr(0, 4) == "tel:") {
     // Use system() for mailto: and tel: URI schemes as ShellExecute() is not working
     // as expected on Windows 7 or 8
     std::string url_prefix = "START ";
     std::string url_command = url_prefix + url.spec();
     if ( ! system(url_command.c_str())) {
       // System call fails. We could display a message to the user as with ShellExecute()
       return false;
     }
  } else {
    // For other URI schemes revert to ShellExecute()
    if (reinterpret_cast<ULONG_PTR>(ShellExecuteA(NULL, "open",
                                                  escaped_url.c_str(), NULL, NULL,
                                                  SW_SHOWNORMAL)) <= 32) {
      // We fail to execute the call. We could display a message to the user.
      // TODO(nsylvain): we should also add a dialog to warn on errors. See
      // bug 1136923.
      return false;
   }

More recently I have also been experimenting within JavaScript with:

window.open('mailto:<email>','_blank ')

storing a reference to that window, then programmatically closing it once opened (as it seems to leave behind a redundant intermediary window in the process of opening the mail client).

Hope this helps!

@benkeen
Copy link

benkeen commented Sep 29, 2017

Any updates on this issue? Still occurring on Windows 7 for me.

@bennycode
Copy link
Contributor

I am also having this issue on Windows 10 (email program doesn't open when clicking a button in an Electron app).

Here is the code that I used:

const {ipcRenderer, shell} = require('electron');

// ... some more code

$(document).on('click', '#sendmail', event => {
  event.preventDefault();
  shell.openExternal('mailto:test@something.com?subject=Test');
});

@vaidyaanand
Copy link

Is there any update on this issue. I am having the same problem.

@Ju66ernaut
Copy link

I am weighing electron as an option for a desktop application (win7+) that requires an email to be created from within the app and this is a crucial feature. Any update on this issue or any proven work-around?

@ideacco
Copy link

ideacco commented Sep 24, 2019

I use it under MAC. When I click on the link, it will open the browser directly and jump to my Gmail... However, my mail client is installed by default on my computer, I want to open it via email client. How do I need to do this?

sendEmail () {
      this.$electron.shell.openExternal('mailto:service@xxx.us')
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests