Crezzer7
Crezzer7

Reputation: 2335

C# - Add a clickable button/text that sends an email in outlook

What I am trying to achieve is this:

I am sending an email to someone within my organization asking them to attend a meeting (this will all be on the same domain, i.e. @gmail.com), From here, I want them to be able to click a button or label, which will send an email to a specific person (so basically a confirmation email that they accept the meeting). I am sending the 1st email in C# by using the following code:

 string theBody = "Do You Accept: " + "Click Here/Button"

 Message objMessage = new Message();
            objMessage.NameFrom = Convert.ToString(ConfigurationManager.AppSettings["SMTPSendingName"]);
            objMessage.EmailFrom = Convert.ToString(ConfigurationManager.AppSettings["SMTPSendingEmailAddress"]);
            objMessage.NameTo = "Subject";
            objMessage.EmailTo = "[email protected]";
            objMessage.EmailMessage =
                string.Format(theBody);

Where I have written "Click Here/Button" is where I would like the clickable text or button, that sends an email back to a hard coded email address, something like the following:

string returnEmail = "mailto:[email protected]?subject=Accepted?body=" + theBody;

To Clarify:

  1. An email is sent to person a from C# using the above code block 1
  2. When person a receives the email, I want them to be able to click a button or clickable text, that in turn sends an email to a person b
  3. This clickable button or text must be embeded in C#
  4. My Organisation are using Outlook 2016

This is they way I though would be best, however I am open to any better suggestions into how I can achieve something like this. Thankyou in advance for your help.

Below is an example image of what I have, as you can see its just a long hyperlink, which does work for now. This opens up a new outlook message, and the user has to press send. I would prefer this to happen all in one click but if this is not possible, then that is ok.

enter image description here

Upvotes: 0

Views: 2254

Answers (3)

PowerMapi
PowerMapi

Reputation: 39

have you considered a custom outlook form? https://msdn.microsoft.com/en-us/library/office/ff868929.aspx

If you're not on an exchange backend, you might have to send the form template around to your users. Exchange allows for "Organizational Forms" which all users can get.

The custom form allows you to add buttons and code-behind in the custom form for very much what you are asking.

Upvotes: 0

Federico Alecci
Federico Alecci

Reputation: 914

You could have an endpoint in your api, that will be hit when the user clicks on accept. On that endpoint, you could use Office365 APIs (https://msdn.microsoft.com/en-us/library/office/dn776319(v=exchg.150).aspx), more specifically, the Calendar API, to accept the meeting.

Upvotes: 1

Dmitry Streblechenko
Dmitry Streblechenko

Reputation: 66255

You can't. HTML in Outlook is rendered by Word, and it will not run any scripts. The best you can is provide a link that will be opened in the user's browser, which can then do something meaningful.

Upvotes: 1

Related Questions