B-Rad
B-Rad

Reputation: 1557

Can I add a Javascript function in C# to a gmail e-mail?

I am using C# and ASP.net to write an e-mail and send using via Gmail.
Basically, the e-mail will contain a list of checkboxes that the person can check. After the check boxes will be some wort of 'Submit' button or link that will use Javascript to check which check boxes have been checked. They will then be redirected to a new page.

So far, I can successfully create the check boxes doing this:

message += @"<input type=""checkbox"" name=""vehicle"" value="" + i + ">Text</input>";

Where i is part of a for loop so each input has it's own unique number value.

I have been trying to do this:

message += @"<a onclick=""myFunction();"" href=""http://www.mysite.com"">Submit</a> ";

However 'myFunction()' is never called. In fact the 'onclick' portion of this HTML doesn't show up in my e-mail when I 'inspect element'. What I get is this:

<a href="http://www.mysite.com" target="_blank">Submit</a>

My goal here is to have a link that would be modified by a javascript function to make it do something like this:

<a href="http://www.mysite.com&CheckedItems=123" >Submit</a>

Where '123' could be parsed later on by 'mysite'.

Upvotes: 0

Views: 419

Answers (2)

SLaks
SLaks

Reputation: 887807

For security reasons, email clients will strip all script and most CSS from emails before displaying them.

You can't do that.

Upvotes: 2

azurelogic
azurelogic

Reputation: 786

This is unreliable. Just find a better way to get people to come to your site through the email to fill out the form.

Reference: Is JavaScript supported in an email message?

Upvotes: 1

Related Questions