[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2798
  • Last Modified:

how to send javascript in email body part using c#

sending email from c#. in body part of email i require to call one java script function ,how to call that function?
0
polythought
Asked:
polythought
  • 3
  • 2
3 Solutions
 
DoctorMahdiCommented:
call it normally
<body>
        <SCRIPT LANGUAGE="JavaScript" src="javascript/polythought.js">
        </SCRIPT>
0
 
adg080898Commented:
The format of the email must be HTML for DoctorMahdi's suggestion to work.

This might answer your question a little more accurately:

<SCRIPT LANGUAGE="JavaScript" src="javascript/polythought.js">
</SCRIPT>

<SCRIPT LANGUAGE="JavaScript"><!--
TheFunctionCall();
// -->
</SCRIPT>

Note that you have to use two separate script tags. If a script tag contains "src=" then the content of the tag is executed only if the js file is not found.
0
 
adg080898Commented:
You could skip the first script tag if you just put the function right there in the email:

<SCRIPT LANGUAGE="JavaScript"><!--
TheFunctionCall();

function TheFunctionCall()
{
   // ... the code...
}
// -->
</SCRIPT>
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
alkisgCommented:
Usually mail programs have javascript disabled.
In thunderbird it is possible to enable it, in Outlook / Express it's not, so it won't run no matter how you write it.
0
 
adg080898Commented:
Looks like I was wrong about the javascript in emails - never have tried it myself and it makes sense to not allow it in emails since it would be easy to lauch a url to notify some server that the message was read. However, simply putting an image link in an email can do that for you. I'm not sure I was wrong, but I probably was.

I suggest either award alkisg the points or a refund.
0
 
alkisgCommented:
> However, simply putting an image link in an email can do that for you.
That's why recent email clients like Outlook forbid automatic image downloading.

Javascript is disabled for safety as well - a .js script could fool the user to open a virus attachment, or use IE vulnerabilities to access the disk etc. Firefox has better organization for script security permissions, and that's why there is an option in Thunderbird to allow javascript (it's not as unsafe as IE).

As for the points, I'm not interested in them, just want to help whenever I can. I leave it up to the Cleanup Volunteers / moderators.

Regards,
Alkis
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now