August Wind Enterprises

New-->Using DatePart and other Date Functions
New-->Understanding Includes
(Updated) Using Single & DoubleQuotes in ASP with SQL Statements
(Updated) Emailing Form Results
Mass Emailing with CDO
Using The Ad Rotator
ASCII Character Set 0-127
Mass CDO
Mass Emailing With CDO

Naturally, first you've got to make a connection to the Database and get a little SQL going:

Set MyConn=Server.CreateObject("ADODB.Connection")
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"DBQ=" & server.mappath("MyDatabase.mdb")
MySQL="Select * from TableName"
Set MyRs=MyConn.Execute(MySQL)

This is the code that actually grabs all the email addresses from the FieldName called 'email'. Once it has all the email addresses (putting a semi-colon in between each of them), it puts it in a variable called 'MyVar'.

MyVar= ""
delimiter = ""
do while not MyRs.eof
If Not IsNull(MyRs("email")) Then
MyVar= MyVar & delimiter & MyRs("email")
delimiter = "; "
End If

Here, we set up the Body of the message - whatever you want, put it here and add vbcrlfs for formatting:

MyBody="This is everything I wanted to tell you." & vbcrlf & _ "Let Me know what you think & let me know." & vbcrlf & "Thank you for your support" & vbcrlf & "David Wier"

We're getting really close here - we instantiate the object that actually does the emailing. What I usually decide to do, is to put my own email address in as the main person to whom it's sent. That way, if I get it, I'm at least fairly certain that the mailing went through ok.

Set objEmail = Server.CreateObject("CDO.message")
objEmail.From = "Bobby@here.com"
objEmail.Subject = "This is the Subject of my Email!!"

Now - here's where we put in all the rest of the names. Remember that variable we created from the loop above? Well, this is where it goes - at least for me, that is. With all the email addresses in the BCC section, it looks like they're all sent individually (at least theoretically).

objEmail.TextBody = MyBody

Here's where you can simply do a response.write to insure yourself that 'MyVar' did indeed, make up all the email addresses you had thought it should:

Response.Write "Your Email was send to the following email addresses:" & MyVar

We must tidy up a little:

Set MyRs= Nothing
set MyConn=nothing
Set objEmail=Nothing
That's all there is too it - that wasn't too hard, was it?

One note of warning, though - - - before you do this, you should delete all email addresses going to Hotmail.com. For some reason, which I have yet to figure out, some emails going to Hotmail.com get in the hotmail system and replicate - 100s or even 1000s to the same email address.

Back to the Top | AugustWind Home

Please, email your questions or comments to : (questions@augustwind.com)
Last Updated 2/22/2011 10:02:28 PM © 2018 August Wind Enterprises - All rights reserved