There are several ways to send an email from VBS (ASP, WSH, IE-HTA, ...) or from VBA (Word, Excel). This page contains sample code to send simple email message for CDO, CDONTS and Outlook objects.
Please see Pure/Huge asp file upload to send emails with attachment from a client side. Live sample of upload a file and send it by email is on Huge-ASP file upload to email sample page.
1. IIS SMTP service, CDONTS.NewMailIf you have IIS SMTP service installed on your machine, you can send an email using the service and CDONTS.NewMail object. This object lets you send text or HTML emails (with attachment/images) by a simple way, but its performance is not so good. You can send only several few emails per second. Next sub shows basic CDONTS.NewMail idea.
2. IIS SMTP service, CDO.MessageCDO for W2k lets you send an email using any SMTP server - you can send the email with IIS SMTP service also.
You can cache configuration and use it multiple times to get a better performance of the object. CDO.Message can send 5 times more messages in the same time than CDONTS.
3. Remote SMTP server, CDO.MessageIf you want to send an email using another SMTP server, you can set configuration properties to the server. See more in Email from ASP - Using external smtp server and CDO article.
4. Send message using OutlookYou can send emails using Outlook also. You can send email over Microsoft Exchange with this object (or another email server, using IMAP/POP).
5. Send message with client-side attachment - Upload to emailThis live sample is located on http://www.motobit.com/util/upload/upload.asp URL. The sample uses Pure-ASP file upload (free ASP include) or Huge-ASP file upload (hi-performance upload component).
Each of email objects have a method to attach one or more files located on disk, the base idea is bellow.
Next is a full source code of upload-to-email sample. The sample processes source HTML form with From, To, Subject and Message fields and one or more file fields, then uses AttachFile method of CDONTS.NewMail object to put uploaded files into email.
for 'Send an email from ASP (WSH) using VBSscript, CDONTS and Outlook.' articleEmail from ASP - Using external smtp server and CDO
Check if a pop3 email account exists in a windows 2003 pop3 serviceLet's you check if a pop3 user email account exists in a windows 2003 pop3 service
Send email from MS SQL using CDO.This stored procedure lets you send an email using CDO.
Copyright and use this code
The source code on this page and other samples at http://www.motobit.com/tips/ are a free code, you can use it as you want: copy it, modify it, use it in your products, ...
If you use this code, please:
1. Leave the author note in the source.
2. Link this sample from you page.
<A Href="http://www.motobit.com/tips/detpg_send-email-from-asp/" Title="Short samples which lets you send an email from ASP or WSH, using several objects (CDONTS.NewMail, CDO.Message, Outlook.Application) and VBScript" >Send an email from ASP (WSH) using VBSscript, CDONTS and Outlook.</A>
© 1996 - 2012 Antonin Foller, Motobit Software | About, Contacts | e-mail: email@example.com
Partner sites: Search Czech Last minute Zajezdy Obsah na mobil Hry na mobil Java Hry Print-shop Affiliate programy
|IISTracer - IIS ISAPI real-time monitor IISTracer is a real-time monitoring tool for Microsoft IIS, which will show/log you what is happenning on IIS server right now. It let's you reveal problems with long-running scripts (.asp, .cgi, cfm...), hang-up states and low resource situations and lets you stop long-running requests (uploads/downloads).||ActiveX User account Manager - Set of simple objects for creating, deleting, and managing user accounts, groups, servers and domains in the Windows NT environment.|
|Active log file - Hi-performance text file logging for ASP/VBS/VBA applications. Lets you create daily/weekly/monthly log files with variable number of logged values and extra timing and performance info.||ActiveX windows registry editor - Intuitive, easy to use COM interface to windows registry. Set of classes to read/enumerate/modify windows registry keys and values from ASP, VBS and T-SQL.|
|ActiveX/ASP Multi Dictionary object - Free-threaded hi-speed dictionary algorithm with unique/nonunique keys (map/multimap). Connect to another dictionary object in the same process. Lock and Unlock methods to synchronize tasks (application scope). Share ASP Application/Session objects.||Export DBF/MDB from ASP - Conversion from recordset to MDB/DBF. Direct binary output of MDB or DBF files from ASP pages with one row of code.|
|Pure-ASP upload - lets you upload files using Pure ASP VBS code (using multipart/form-data and input type=file).||ByteArray - Works with safearray binary data (VT_UI1 | VT_ARRAY) - save/restore binary data from disk, find, work with code pages, convert to string/hexstring(SQL).|
|WebChecker - Checks http, https, ftp and gopher internet connections in regular intervals. Lets you monitor web site functionality (uptime). Enables restart or notification on problems.||HTTPLog ISAPI filter - Lets you log incomming/outgoing http header and document data to separate files. Monitor of IIS service input/output.|