Onclick of UI Action, an email client should be opened with some body of data autopopulated.

Kethe Yamini
Tera Contributor

Onclick of UI Action, an email client should be opened with some body of data autopopulated.I am using this function-emailClientOpenPop to populate some different to,subject and body.It is not working.please help me with any other functions we can achieve this

2 REPLIES 2

mihirlimje867
Tera Guru

Hello @kethineni ,

Please try this logic:

// Define the email parameters
var to = "recipient@example.com"; // Add the recipient email
var subject = "Your Subject Here"; // Define the subject
var body = "This is the body of the email.\n\n"; // Define the email body

// Encode the subject and body to be URL-friendly
subject = encodeURIComponent(subject);
body = encodeURIComponent(body);

// Construct the mailto link
var mailtoLink = "mailto:" + to + "?subject=" + subject + "&body=" + body;

// Open the email client
window.location.href = mailtoLink;

 

Thank you.
Please hit on the helpful button

Hello @mihirlimje867 

I don't want to use outlook email. I need to use email client within the ServiceNow. Please provide your inputs based on this.Thank you!