简体   繁体   中英

JS/PHP : Email Compose and add attachment in Outlook

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>

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

在此处输入图片说明

在此处输入图片说明

This is the result of my running:

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM