Solved

how to send javascript in email body part using c#

Posted on 2006-11-16
9
2,580 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

This is about my first experience with programming Arduino.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
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 …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now