Kapil
Kapil

Reputation: 9969

How to open outlook mail compose window in chrome app?

I'm working on a chrome application which needs to create an email on click of a button. I'm using mailto: for that and since default client is Outlook, it should open outlook email compose window. I'm using below code for same -

var mail = "mailto:" + recp + "?subject=" + sub;
newWindow = window.open(mail);

When this is executes, chrome app opens outlook email window but also opens a tab in chrome with url as contents of mail variable . and even if I call close on the newly created tab, that does not get closed. My goal is to create email without any additional tab.

Is there any way I could achieve this

Upvotes: 1

Views: 9479

Answers (1)

Justinas
Justinas

Reputation: 43507

You don't have to open new window for this link, since there will be auto-open outlook window (I have no associated action with that type of link, so I get popup to select with that program to open it)

$("span").click(function() {
  var recipient = $(this).text();
  window.location.href = "mailto:" + recipient + "?subject=Mail to " + recipient;
});
span {
  cursor: pointer;
  display: inline-block;
  margin: 0 10px;
}
span:hover {
  border-bottom: 1px dotted black;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span>[email protected]</span>
<span>[email protected]</span>
<span>[email protected]</span>

Upvotes: 1

Related Questions