50
Views
6
Comments
Send Email with a button,click the button, the browser window does not open


hello everyone,

I have a question, what should I do if I need to send an email containing a button, click the button without opening any browser, and directly return the value I need?

I tried using the Reactive RestAPI as the URL for the link, but it still opened the browser.

I tried traditional email content, but the button can only be written in the Block, and after sending, the button cannot be seen in the email.

UserImage.jpg
Md Mansur

Hi @LeonKT 

I think your Requriment is you have send a email for a person and when the person recived a email so that email body part have a button and when you click that button you don't want to go to your application or you direct want to update some value without go to your application???

If this reequriment is Correct that it is not possible to update any value or retun any value without intract with your app ui /broweser

Thanks

Md Mansur

2020-01-21 02-48-16
LeonKT

Thank you for your reply,Mansur.The Requriment is exactly what you say it is,I tried a lot of things, but it was really hard to implement on the outsystems platform, and the requirement seemed unreasonable.

2024-03-23 18-16-49
Bryan Villalobos

Hi @LeonKT ,

The reason why links or buttons opens up a browser is because email clients are not capable of posting or accessing webpages. It does not understand http. That's why it opens up a capable application to do the job, a web browser. Also, even if this is possible, having a button that does not do anything is probably going get them to click it multiple times, leading them to become very frustrated with the email.

I believe you may need to change your approach on this. 

I am not sure why you need to return a value. But if you need to, it would be much better to just open up the browser and redirect the user to your application that will make them return the value you want, or something that can make them entertained or interact with it.

Regards,

Bryan

2020-01-21 02-48-16
LeonKT

Thank you for your reply, Villalobos.If that is true, I may not be able to implement this feature, in fact, this button is limited to only one click.

2024-10-12 12-11-20
Kerollos Adel
Champion

@LeonKT 


Unfortunately, due to the nature of how emails and web technologies work, the behavior you're aiming for (triggering an action without opening a browser or performing an HTTP request) is not directly possible, because email clients are designed with strict security restrictions. Let me explain why and offer some potential alternatives that might work for your use case.

Why It Doesn't Work

  1. Email Client Limitations:

    • Email clients (like Outlook, Gmail, etc.) are extremely restrictive when it comes to executing scripts or code within an email. This is for security reasons—to prevent malicious actions like phishing or automatic data collection.
    • Even if you try to embed scripts (like JavaScript) in an email, it won't execute because email clients block such active content. Similarly, direct calls to APIs (like a REST API) from an email button are not possible without user interaction (like opening a browser).
  2. Button Behavior in Emails:

    • When you insert a button in an email, it's typically just an HTML anchor (<a> tag) that redirects to a URL when clicked. This is why clicking your button is opening a browser.
  3. Reactive REST APIs in Emails:

    • While you can link to a REST API endpoint from an email, as you noted, this will always open a browser. The reason is that the email client cannot perform an API request on its own. It relies on the user clicking the link, which then opens in the browser to perform the action.

Alternatives & Workarounds

Since you can't trigger an action from an email directly without opening a browser, here are some alternative approaches to achieve something similar:

1. One-Click Actions (via REST API or Redirect URL):

  • How it works: Instead of attempting to call an API directly from the email, you can generate a URL that includes all the necessary parameters for your action (e.g., an identifier or token) and redirects the user to a simple page.
  • When the user clicks the button, the browser opens and automatically sends the request, performing the action without requiring further interaction.

2. Server-Side Email Handling (Email-Based Action Confirmation)

If browser interaction isn't ideal, consider email-based workflows where the user replies to an email to trigger an action.

How it works:

  • When the user receives the email, they can reply to it (for example, with "YES" or "CONFIRM") to perform the action.
  • Your server or OutSystems module would handle the incoming emails and trigger the necessary actions based on the reply.

3. Link Shortening Services for User Tracking (Optional)

If you're concerned about opening a browser but still want to track when a user clicks the link, you can use services like Bitly or OutSystems' built-in link generation to create shortened URLs. This can also help you log who clicked the button and when the action was triggered.


2019-01-07 16-04-16
Siya
 
MVP

As other members stated it is not possible execute JavaScript as email client blocks the same. 

If your requirement is to show some status as "image" dynamically when an email is opened then there is an option. Have an image in your email and set the image source as OutSystems REST end point and based on the input parameter you generate an PNG ( using imageToolbox forge component ) or SVG file and return. You also need to set the correct content-type (image/png or image/svg+xml) using AddHeader method.

SVG would be faster as you can create it  without depending on any forge component but do check the compatibility of SVG rendering on email clients.

Note : Please be aware of the security implications as these are open to internet and there will not be any authentication.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.