Sending buttons in email in c#

Viewed 39

I want to send two buttons in email. On clicking of that buttons user should be able to Approve or Reject approval. It should work on gmail as well as outlook. I am not sure if web api will work. I am using c# for sending email. Please share any idea.

1 Answers

Email clients (Outlook as well) don't allow executing any JavaScript code in the message body for security reasons. The best what you could do for all mail clients is to paste a hyperlink in the message body and count responses on the server side when users click it.

As for for Outlook, you can use the MailItem.VotingOptions property which allows setting a string specifying a delimited string containing the voting options for the mail message.

Voting options on messages are used to give message recipients a list of choices and to track their responses. To create voting options programmatically, set a string that is a semicolon-delimited list of values for the VotingOptions property of a MailItem object. The values for the VotingOptions property will appear under the Vote command in the Respond group in the ribbon of the received message.

    using Outlook = Microsoft.Office.Interop.Outlook;

    private void OrderPizza()
    {
        Outlook.MailItem mail = (Outlook.MailItem)Application.CreateItem(
            Outlook.OlItemType.olMailItem);
        mail.VotingOptions = “Cheese; Mushroom; Sausage; Combo; Veg Combo;”
        mail.Subject = “Pizza Order”;
        mail.Display(false);
    }
Related