How do I allow a user approve a task from the email? - javascript

In our project the managers receive emails with their tasks. The new requirement is to allow the managers to approve their tasks from the emails. Near every tasks is an "Approve" button that should be added to allow approvals of tasks without going to the site of the company.
How do I do it?

As for me, that is not possible. Most email clients will never run javascript, so you can't use ajax to call your server.
Another option - iframe with a form to set an approval in it. According to this in some email clients it will work. In others - no.
As for me, the most realistic way is to put a simple link. Click on it will open browser, of course, but you can make that page close itself after everything is done.
The last option I see is to send an email to some specific address, like approve_task#company.com with subject containing an ID of a task and establish listener which will check email received by approve_task#company.com and mark task as approved. No problem to make a mailto: link in email body. But you can't send any emails automatically. Managers will need to click it and send an email manually. So I do not think this is really good solution.

Related

How to trigger an API call on a button click inside an Email Template

This is a use case where an API has to be triggered when the user clicks a button on his/her email. The API call should hit the server to do some action in backend.
I tried some javascript (fetch, XMLHttpRequest), but also came to know that all email clients do not support javascript. Is it right? Is there any options other than javascript?
Most (nearly 99%) of mail clients and servers will put the mail with JS into spam or won't even let it into your inbox. Even the mail client must be able to work with JS. While in Outlook it can be enabled with plugins, you have to be 100% sure, that the receiver will receive it, otherwise you can`t do it.
Another way to fetch data/get mail info like statistics is to add a unique ID to all links used in the mail. By chance, the user will click on it and you can work with the data on server side.
But as allready mentioned: Don`t use JS in your mails. It's not ment for mails.

Is there any way to get the email address of the one who clicked the link on outlook

I developed an application in which all the processes of organization is going to be handle online .
There are some processes which were run manually and it took time , now it is going to approve or disapprove online.
Let say there is an document who is going to be approved by HR ---> ADMIN ---> CEO.
Now when some one initiate a request application send two links to HR manager which is approve or disapprove , and HR can perform their action by clicking those link.
What is happening it if HR manager send this links to someone else , SO , That person can also approve or disapprove the process , although he is not the right person to do.
I can stop it by implementing authentication process on those two links , Than every authority must have to login in the application . which i don't want.
Is there any way that i can pick the email id of the person who click that link , so i can compare the email address on back end ?
As I see it you have 3 possible ways of doing this:
1: Implementing an authentication process
This is the best approach in my opinion as you can be sure that the person who should approve the process is the person actually approving it.
The con with this approach is that the users will have to log in, but you could implement this in such a way that they rarely have to, for example they could stay logged in for one a month or longer.
2: Using a link with a one time token
This is basically the approach you mentioned with the con that you mentioned, namely that someone can just forward the email and someone else can then approve it.
The only way in your case for this to work is if it's enforced from the top down, as in management could impose a penalty if such an email is sent to someone else. But this is rarely a good strategy and would be difficult to enforce.
3: Approve and Disapprove with a reply email
I think this approach might be the closest to what you're looking for, but as a disclaimer I've not tested something like this before.
You could setup the links in such a way that clicking on them will open a new mail screen with certain things populated, for example you could populate the subject and the address to send the mail to.
Example link: Approve
Then within the system you're creating you'll have to monitor that mailbox and then parse any email received, using the from address to validate if the correct person has sent the email.
A big note with this approach is that the from address in an email can easily be spoofed, so if you want to take this approach, I'd recommend at least adding some sort of random token in the email as well that will be validated on the back end.
Even with the unique token, there exists another vector of attack, although it would take some work. Let's say the system sends a mail to Alice because she needs to approve or disapprove something, she forwards the mail to Bob. Bob can't click on the link and send the email as is, because the system will see that it came from his email address, but what Bob can do is click on the link to see what the subject should be, and then spoof Alice's email using a spoofing site. The system would then see everything as in order because it will look like the email came from Alice.
Example spoofing site: https://emkei.cz/

How to add Textbox and buttons to gmail messages and get the responce from them

I want to add two buttons to my gmail messages YES and NO if we pressed on YES then show one Textbox and a submit button .and if we press on submit button the value od the textbox must be saved. how can i achieve that . Am sorry for my bad language
You can do this simply using google form. Just follow the steps below
1) Go to google forms create a new form as you like
2) then click on send form choose send via email option mention the to email address, subject and message. Don't forget to check Include form in email option.
Then click on send button.
When the recipient receive this email that would contain an embedded google form. The responses of google form can be retrieve via email or it can be save into a linked excel file on google drive.
I think the easiest way to your problem is to put Links in your E-Mail, which redirect the user to a website of yours. If he presses no, then your website (where the user was redirected from the no-button) can just save the response and close the tab again. If the user presses yes, the user can enter the information in the textbox (in your website from the link from the yes-button) and save it on your website after the user submitted it.
That's usually the practice how such things work. Another example for this is unsubscribing from newsletters. There you also get redirected to the website of the sender of the newsletter and may enter your e-mail and the reasons why you unsubscribe.
Hope I could help :)
it may be a number in the textbox like number of persons ,and it save
to a web server . can we do that ?
In pure e-mail based on HTML and JavaScript? No. You can't. You need PHP to send response to server and this is not allowed in e-mails and with JavaScript is basically impossible to do it. next problem is, that you cant use iframe or something like this, because Gmail and other e-mail clients don't allow it.
But how?
You can create good looking button with HTML/CSS and on it add link to answer to your page, where you can easily process user data. If you haven't got many programming skills you can use Google Forms. Google Forms is easy to use for any user and you can create your own form without having server, because all data will save at google for free
+ it have API.
Plus Google Forms have function for sending forms via e-mail!
(Sorry for Czech in image.)
Good luck!

Email API for connecting in a marketplace?

I'm looking into what it would take to add a feature to my site so this is a pretty naive question.
I'd like to be able to connect buyers and sellers via an email message once the buyer clicks "buy".
I can see how I could do this in java script, querying the user database and sending an email with both parties involved. What I'm wondering is if there's a better way I can do this, playing monkey in the middle so they only receive an email from my site, and the it's automatically forwarded to the other party. That way they don't have to remember to hit reply-all, just reply. Also their email addresses remain anonymous.
Again assuming I generate a unique subject line with the transaction ID I could apply some rules here to just automatically forward the email from one party to the other but is there an API or library which can already do this for you?
What you're describing would be handled largely by your backend. If this were my project, I would choose the following simple route:
Store the messages the buyers/sellers send in your own database, then simply send notification emails when messages are sent. Have them reply to each other on your own site, like Facebook and eBay do.
An example flow would go like this:
(Gather the user and buyer's email addresses via registration)
Buyer enters a message and clicks 'Send Message' button on seller's page
Form is posted (via AJAX or via POST) to a backend script
Your backend code generates an email message
Sets the 'To' field to the seller
Your seller gets an email alert of the potential buyer which shows the buyer's message
The Seller then logs on to your site (made easy by a URL in the email) to respond
The Seller enters a response message on your site and hits 'Reply'
Buyer gets an email notification with the message body and a link to your site where they can compose a reply.
...and so on. So, replies would have to be authored on-site, rather than as an email 'reply.'
If you choose to go this route, there are some simple 3rd party "transactional email" providers, which is the phrase you'd use to find them. I've personally used SendGrid and found them easy to set up and use. They have a simple plug in for every major framework. There is also Mandrill, which is newer but gets good reviews as well.

AJAX in email body?

Is there a way to load dynamic content into an email when it is rendered? Recently I had to rebook a flight and the booking agent told me to close out of the email on my phone so they could give me a new itinerary. How are they piping dynamic content into the email? AJAX? I thought JS didn't work in emails.
AJAX does not run in most email clients - it's a security risk. The only thing I can imagine is that they can change pictures. Pictures are usually reloaded from the server everytime you open the email. Other than that, the person talking to you just might not understand how emails actually work.

Categories