Sending E-Mails with ASP Pages
Sending E-Mails with ASP Pages
| Author: | Tom Vergote |
| Submission Date: | 2006-04-20 |
| Website: | |
| Email: |
Overview
Sending an email with asp is fairly easy, all you need is CDONTS (Collaboration Data Objects for NT Server, installed with IIS), or a special component like AspEmail ( free ) by Persits Software Inc (there are more available). 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.
Comments by the Author
Please post a lot of comments, as this is my first article. Tell me what you like/dislike so I can improve my future articles.
| Rate this article: Lowest = 1 to Highest = 5 |
|
| View PDF Bookmark Printer Friendly | |
