faqts : Computers : Programming : Languages : Asp : ASP/VBScript : Common Problems : email

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

24 of 28 people (86%) answered Yes
Recently 9 of 10 people (90%) answered Yes

Entry

How can I send an email using ASP?

Jun 20th, 2000 07:27
unknown unknown, Eric van Buren, Porello Adam


Have a look here:

http://www.4guysfromrolla.com/webtech/112298-1.shtml

-----

You can use the CDONTS component which is installed when the SMTP
service with IIS4 is installed.  The same service is installed 
automatically with IIS5.

To send an email using CDONTS, you could use some script similar to the
following

                'Create an instance of the CDONTS object
                Set objEMail = Server.CreateObject("CDONTS.NewMail")
                'Who the email is going to
                objEMail.To = rs("Email")
                Who the email is from
                objEMail.From = "OSFA_Webmaster@ed.gov"
                'Optional setting
                objEMail.Bcc = "eric_Vanburen@ed.gov"
                'Set the subject
                objEMail.Subject = "A new job has been added to the OSFA 
Job Board."
                'Define the body
                strBody = "Dear OSFA Job Seeker," & vbCrLf & vbCrLf
                strBody = strBody & "A new position has been added to 
the OSFA Job Board.
Details of the position are below." & vbCrLf & vbCrLf
                objEMail.Body = strBody
                'Send the email
                objEMail.Send
                'Clean up
                Set objEMail = nothing

-------------

Heres some code which drops an email into the pickup folder of the SMTP
section of IIS.  This code has been cut from one of my live web pages.


MsgFrom = "Webmaster@tarmac.co.uk"
MsgTo = "webby@aol.com"
MsgSubject = "auto emails"
MsgBody = " A user has logged on whos browser is out of date, it is only
running version "&strversion&" of "&strbrowser&".  They are activly 
using
the browser.  Please update their browser"


Set Filesys = CreateObject("Scripting.FileSystemObject")
Set 
Peoplefile=Filesys.OpenTextFile("C:\inetpub\mailroot\pickup\email.",8,TR
UE)
Peoplefile.Writeline "x-sender: "&MsgFrom
PeopleFile.WriteLine "x-Receiver: "&MsgTo
PeopleFile.WriteLine "From: "&MsgFrom
PeopleFile.WriteLine "To: "&MsgTo
PeopleFile.Writeline "Subject: "&MsgSubject
PeopleFile.Writeline 
PeopleFile.WriteLine MsgBody
Peoplefile.Close



© 1999-2004 Synop Pty Ltd