0

I have created one portal where I want to configure outlook with the portal. There will be Email button where on click outlook should get open where subject, body and attachment should be added automatically based on data in the database.

I can open outlook and set subject and body but don't know how to add an attachment.

I have checked this link Javascript: Outlook but I am getting ActiveX exception but I believe this is more compatible with IE. Also , Microsoft - Outlook

<html>
<head>
<script>
function myFunction() {
    window.location.href = "mailto:test@test.com?subject=TestSubject&body=message%20goes%20here";
}
</script>
</head>
<body>
<button onclick="myFunction()">Open Outlook</button> 
</body>
</html>
kreya
  • 1,091
  • 5
  • 24
  • 52

1 Answers1

0

According to your description, you want to add an attachment with JS, you can use the following code:

mailItem.Attachments.Add("your prfile url");

You need to set “Initializing and scripting ActiveX controls that are not marked as secure” to enabled.

In IE

enter image description here

enter image description here

This is the result of my running:

enter image description here

Alina Li
  • 884
  • 1
  • 6
  • 5
  • Thanks for the solution. But we cannot change the internet settings. Is there any library or other way we can do this ? – kreya Sep 28 '18 at 09:54
  • Can you change the registry – Alina Li Sep 28 '18 at 10:14
  • No we cant. We cant ask customer todo that – kreya Sep 28 '18 at 10:32
  • IF not, you could use Firefox. Firefox users can install ff-activex-host plugin to enable ActiveX controls in the browser. This plugin makes it possible to use (host) ActiveX controls in Firefox and provides full access to the hosted control (events, functions, properties). Reference: https://stackoverflow.com/questions/20118868/enabling-activex-control-in-chrome-and-firefox – Alina Li Sep 28 '18 at 10:40