Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send mail using javascript?

Status
Not open for further replies.

NPG

Programmer
Mar 9, 2001
9
0
0
GR
I need to send a mail using javascript with
an attachment from a client-side script.Is there any
method?I think that this can be done using Netscape.
I dont want mailto or script using Outlook 98/2000!
Thanks!
 
If you need to run the script client-side, you will probably have to use a cgi (which would actually run on the server anyway) unless you use mail-to, because client-side you would be using the viewer's email (like Outlook, etc.)
If you need a simple script, you can run it server-side on as asp page using CDONTS, something like this:
var objNewMail = Server.CreateObject("CDONTS.NewMail");
objNewMail.BodyFormat = 0;
objNewMail.MailFormat = 0;

var strBody = &quot;<html>&quot;;
strBody = strBody + &quot;<head>&quot;;
strBody = strBody + &quot;<meta http-equiv='Content-Language' content='en-us'>&quot;;
strBody = strBody + &quot;<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>&quot;;
strBody = strBody + &quot;<title>Mail message</title>&quot;;
strBody = strBody + &quot;</head>&quot;;
strBody = strBody + &quot;<body>&quot;;
strBody = strBody + &quot;<p><font face='Arial' size='2'><u>body text here</u></font><br>&quot;;
strBody = strBody + &quot;</body>&quot;;
strBody = strBody + &quot;</html>&quot;;
objNewMail.Body = strBody;

objNewMail.From = &quot;someone@somewhere.com&quot;;
objNewMail.To = &quot;someone@somewhere.com&quot;
objNewMail.Cc = &quot;someone@somewhere.com&quot;;
objNewMail.AttachFile = &quot;c:\filename.txt&quot;;

objNewMail.Subject = &quot;subject&quot;;

objNewMail.Send();
objNewMail = null;
Your server has to be set up to work with CDONTS.
Of course, if your attachment is coming from the client, that's different, and you are back to using a cgi.
 
Thanks crowell but I need a client side script!
Is there some way to use port 25 directly from javascript?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top