Open Outlook Client using Declarative Actions

Meet Mewada
Tera Expert

Hi Team,

 

My use case is to open an outlook email upon clicking a button on a workspace form. I thought to use a declarative action implemented as a server script which includes below line:

action.setRedirectURL("mailto:recipient@example.com")
 
I also tried, gs.setRedirect("mailto:recipient@example.com") & gs.setRedirectURL("mailto:recipient@example.com")
 
However, this doesn't work. Any suggestions to achieve this use case?
 
Thanks in advance.
 
Regards,
Meet M
1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Meet Mewada 

you need to use client side UI action and write code in workspace client script for this.

Something like this

 

function onClick(g_form) {

    var email = 'recipient@example.com';
    var subject = 'Subject of the email';
    var body = 'This is the email body.';

    // Construct the mailto link
    var mailtoLink = 'mailto:' + email + '?subject=' + encodeURIComponent(subject) + '&body=' + encodeURIComponent(body);

    // Open the email client
    open(mailtoLink);
}

 

AnkurBawiskar_1-1751872623593.png

 

Output: when I clicked it opened this

AnkurBawiskar_0-1751872601421.png

 

 

Then I selected Outlook app and it opened the email form

AnkurBawiskar_0-1751872816982.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

6 REPLIES 6

Shubham_Jain
Mega Sage

@Meet Mewada 

 

    •  
    • Go to UI Builder for your Workspace.
    • Select the form or component where you want the button.
    • Add a Declarative Action:
      • Action Type: Open URL
      • URL:
        mailto:recipient@example.com?subject=Hello&body=This is a test email
      • Attach this action to a Button Component:
        • On click, it will trigger the mailto: link and open the default email client (e.g., Outlook)
  1. Important Notes:

    • This must be done client-side — server-side scripts like gs.setRedirect() won’t work for mailto: links.
    • Ensure your browser allows pop-ups and default email client is configured.

 

✔️ If this solves your issue, please mark it as Correct.


✔️ If you found it helpful, please mark it as Helpful.



Shubham Jain


HI @Shubham_Jain 

I am unable to find Action type: Open URL.

Refer screenshot:

 

MeetMewada_0-1751872625077.png

 

@Meet Mewada 

 

Why "Open URL" Might Be Missing:

  1. Action Type Limitations

    • The "Open URL" action type is not available by default in all workspace configurations.
    • It may be restricted to certain Next Experience-based interfaces or require specific UX Framework (UXF) components.
  2. Missing UXF Client Action

    • You may need to create a UXF Client Action that performs the URL opening logic.
    • This is especially true if you're trying to open external links like mailto:.

 

 

✔️ If this solves your issue, please mark it as Correct.


✔️ If you found it helpful, please mark it as Helpful.



Shubham Jain


Ankur Bawiskar
Tera Patron
Tera Patron

@Meet Mewada 

you need to use client side UI action and write code in workspace client script for this.

Something like this

 

function onClick(g_form) {

    var email = 'recipient@example.com';
    var subject = 'Subject of the email';
    var body = 'This is the email body.';

    // Construct the mailto link
    var mailtoLink = 'mailto:' + email + '?subject=' + encodeURIComponent(subject) + '&body=' + encodeURIComponent(body);

    // Open the email client
    open(mailtoLink);
}

 

AnkurBawiskar_1-1751872623593.png

 

Output: when I clicked it opened this

AnkurBawiskar_0-1751872601421.png

 

 

Then I selected Outlook app and it opened the email form

AnkurBawiskar_0-1751872816982.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader