Solved

how to send javascript in email body part using c#

Posted on 2006-11-16
9
2,610 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
  • 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

A short article about a problem I had getting the GPS LocationListener working.
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

776 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