Click to See Complete Forum and Search --> : sending email from ASP code


Lord Zarm
July 12th, 2002, 12:17 PM
How can I send an email from ASP code?

ScaryBinary
July 12th, 2002, 04:11 PM
I just got some e-mail up and running from my intranet site using CDO for NTS. Writing the code is a piece of cake. Here's all you need to send an e-mail (note that I am NOT using ASP.NET, which I think has some better SMTP stuff....)


Set objMail = Server.CreateObject("CDONTS.NewMail")
objMail.To = "john@somewhere.com"
objMail.From = "marsha@somewhere.com"
objMail.Body = "I cannot go on like this. " & _
"I'm leaving you and I'm taking the computer."
objMail.Subject = "Dear John..."
objMail.Send
Set objMail = Nothing


My headache was getting the SMTP server setup properly (we were using one that was on a different server than the website, but we got it working).

Hope this helps out. Do a search on "Mail" in these formums, I'm pretty sure I saw some stuff that wasn't CDO for NTS.

Igor Soukhov
July 13th, 2002, 02:52 PM
Originally posted by Lord Zarm
How can I send an email from ASP code?
using StmpMail class of Framework Class Library making sending email from ASP.NET extremly easy:


string from = "from@microsoft.com";
string to = "to@microsoft.com";
string subject = "UtilMailMessage001";
string body = "<html><body>UtilMailMessage001 - success</body></html>";
SmtpMail.Send(from, to, subject, body);


If you need more features (e.g. attachements or you have to send message using particular encoding) - just look up to MSDN and seed documentation on these FCL classes : SmtpMail, MailAttachment, MailMessage.

Lord Zarm
July 16th, 2002, 02:58 PM
Set objMail = Server.CreateObject("CDONTS.NewMail")

This crashes. Do I need to setup some CDONTS or something. I am trying to get this working on a test server. Using Personal Web Manager (mircosoft)

thanks