|
|
Sending E-Mails with ASP Pages - ASP Webmaster Tips, Knowledge Base Webmaster Tools
| Home > ASP > Sending E-Mails with ASP Pages | |
| | Category | : ASP | | Written by | : Admin | | Date | : 2008-11-10 | | Rating | : 0 | Voted : 0 times | | Hit | : 234 | | | | |
| Sending an email with asp is fairly easy, all you need is CDONTS (Collaboration Data Objects for NT Server, installed with IIS). In this article I'll show how to send emails with CDO, because it's available to everyone and components work in a very similar way. First we have to create instance of the NewMail object.
<%
Option Explicit
Dim objCDOMail
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
%>
The methods and property's of this object are very obvious.
<%
objCDOMail.To = "somebody@somewhere.com" 'the destination
objCDOMail.From = "me@mydomain.com" 'the sender
objCDOMail.cc = "info@mydomain.com" 'carbon copy
Dim txtBody
txtBody = "This email has been sent by an asp script"
objCDOMail.Subject = "CDONTS" 'the subject
objCDOMail.Body = txtBody 'the body
objCDOMail.Send 'fire off the email
%>
So far it has been pretty easy, hasn't it? There's more.
<%
objCDOMail.AttachFile("c:\wwwroot\mysite\" & _
"MyAttachement.doc", "pricelist.doc")
objCDOMail.Bcc("blind@mysite.com")
objCDOMail.Importance = 1
%>
The first rule defines an attachment ("PATH\TO\FILE", filename_that_appears)
The second rule sends a blind carbon copy
The third rule specifies the message's importance
Importance:
0 -> low
1 -> default
2 -> high
Thats it, I hope this article has been useful and i hope that now you will feel confident sending automated newsletters, confirmation emails and so on.
|
|