Solved

how to send javascript in email body part using c#

Posted on 2006-11-16
9
2,695 Views
Last Modified: 2008-01-09
sending email from c#. in body part of email i require to call one java script function ,how to call that function?
0
Comment
Question by:polythought
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
9 Comments
 
LVL 5

Accepted Solution

by:
DoctorMahdi earned 84 total points
ID: 17956458
call it normally
<body>
        <SCRIPT LANGUAGE="JavaScript" src="javascript/polythought.js">
        </SCRIPT>
0
 
LVL 8

Assisted Solution

by:adg080898
adg080898 earned 83 total points
ID: 17959382
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
 
LVL 8

Expert Comment

by:adg080898
ID: 17959405
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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 9

Assisted Solution

by:alkisg
alkisg earned 83 total points
ID: 17959728
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
 
LVL 8

Expert Comment

by:adg080898
ID: 18398179
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
 
LVL 9

Expert Comment

by:alkisg
ID: 18400976
> 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This is about my first experience with programming Arduino.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Six Sigma Control Plans

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question