Sending an Email in ASP is pretty straight forward. The code is below:
Set objEmail = Server.CreateObject("CDONTS.NewMail")
objEmail.to = "to_email@gmail.com"
objEmail.From = "your_email@domainname.com"
objEmail.Subject = "Subject"
objEmail.Body = "Email Body"
objEmail.send
Set objEmail = nothing
There you go thats how you send an email. Now lets break it down!
This creates a NewMail object from the CDONTS library.
Code:
Set objEmail = Server.CreateObject("CDONTS.NewMail")
The To property lets you specify who the email is to, rather self explanatory! The property has the following form
Code:
objEmail.to = "to_email@gmail.com"
The From property lets you, guess it, specify who the email is from. and it looks like this;
Code:
objEmail.From = "your_email@domainname.com"
This is getting rather repitive don't you think? The subject property lets you define the subject and looks, and you may have already guessed, like this;
Code:
objMail.Subject = "Subject"
Now to the body section. This sets the text of the message, or HTML, which we'll look at soon. And it looks like this;
Code:
objMail.Body = "Email Body"
Code:
objEmail.send
Code:
Set objEmail = nothing
Thats it to send an email. If you need any other help please post your comments below
1 comment:
i have tried this code but it is not working...Is there any other method to send mail through asp
Post a Comment