Need to fix the clickable link to send email
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2023 08:51 PM
I need to fix a clickable link which was mentioned on a service portal page. The link is named as 'Send Report in Email', which is not working.
Please find the code from the attachment. I have also shared the HTML of that portion.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2023 11:56 PM
The code you provided is using ActiveXObject, which is specific to Internet Explorer and older versions of Microsoft Office. It is not supported in modern browsers like Chrome, Firefox, or Edge. Therefore, the code will not work in most modern browsers.
If you need to send an email from a web page, you should consider using server-side code or a third-party email service provider that offers APIs. Here's an example of how you can achieve this using JavaScript and an email service provider's API:
```javascript
function sendMail() {
var mailBody = document.getElementById('printView').innerHTML;
var recipientEmail = 'recipient@example.com';
var subject = 'Problem Executive Summary Report';
// Make an API call to your server or use a client library for the email service provider
// Pass the mailBody, recipientEmail, and subject as parameters
// Example using a fictional email service provider called "EmailService"
EmailService.sendEmail(mailBody, recipientEmail, subject)
.then(function(response) {
// Handle success response
console.log('Email sent successfully:', response);
})
.catch(function(error) {
// Handle error
console.error('Error sending email:', error);
});
}
```
In this example, you would need to replace `EmailService` with the actual API client library or code provided by your chosen email service provider. You will also need to configure the email service provider with your credentials and email settings.
Regarding the HTML code, it seems fine, and the `onClick` event should trigger the `sendMail()` function. However, since the code inside the `sendMail()` function relies on unsupported ActiveXObject, it won't work as intended.
To make the highlighted link work, you need to update the code to use a different method for sending emails, such as the example provided above using a server-side solution or an email service provider's API.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2023 11:56 PM
function sendMail() {
var mailBody = document.getElementById('printView').innerHTML;
var recipientEmail = 'recipient@example.com';
var subject = 'Problem Executive Summary Report';
// Make an API call to your server or use a client library for the email service provider
// Pass the mailBody, recipientEmail, and subject as parameters
// Example using a fictional email service provider called "EmailService"
EmailService.sendEmail(mailBody, recipientEmail, subject)
.then(function(response) {
// Handle success response
console.log('Email sent successfully:', response);
})
.catch(function(error) {
// Handle error
console.error('Error sending email:', error);
});
}