Advertisement

04.20.2008 at 11:07AM PDT, ID: 23337952
[x]
Attachment Details

Sending multiple emails

Asked by bogorman in Microsoft Visual Basic.Net

Tags: ,

I want to send a number of emails using ASP. The email addresses are held in a mySQL table.
I would like to send the first email direct ,with BCCs to the remaining ones in the table (or rather generated by a query of the table).
My present coding just sends emails without BCCs:

Dim Mail
Dim objCDOSYSCon , objCDOSYSMail, BodyString, ResponseString, myRS, db, strSQL, strSQL2
Dim mySQLWhere, MonthString, Connection, FullLoginName, Prompt, UserID, myCmd, myCmd2, RecordID, EmailTextID
Dim EmailText, strFinalMsg, NumberSent, NumberNotSent, strHeader, BodyText, NumberRemaining
EmailTextID = CCGetParam("ID", Empty)
strSQL="ID = " & EmailTextID




Set Connection = New clsDBConnection1
Connection.Open
UserID = Connection.ToSQL(CCGetUserID(), ccsInteger)
EmailText = CCDLookup("fldtext", "tblemailtext", strSQL, Connection)
FullLoginName = CCDLookup("fldFullName", "tblpasswords", "fldID = " & UserID , Connection)

'response.Write EmailText
'response.end

'This prevents the form from being Cached.
Response.Expires = 0
Response.Expiresabsolute = Now-1

'Create the MailSender Object
Set Mail = Server.CreateObject("Persits.MailSender")
Set myCmd = Server.CreateObject("ADODB.Command")
Set myCmd2 = Server.CreateObject("ADODB.Command")
Set myRS = Server.CreateObject("ADODB.Recordset")

'Specify your SMTP Mail Server
Mail.Host = "mailA28.webcontrolcenter.com"

'Specify the From Address and Name
Mail.From = "brianog@DomainID54847.com"
'Mail.From = "matthewo'gorman@lifecharity.org.uk"
'Mail.FromName = FullLoginName
Mail.FromName = "Matthew O'Gorman, LIFE London"
Mail.Subject = "LIFE talks"

strHeader = "<HTML><BODY BGCOLOR=#FFFFFF TEXT=#000000> " & _
"<!DOCTYPE HTML PUBLIC ""-//IETF//DTD HTML//EN"">"
'EmailText & "</BODY></HTML>"

'Mail.Body = strFinalMsg



'Specify of the message is plain text or HTML
Mail.IsHTML = True


strSQL = "SELECT tblselectedschools.fldContact AS CONTACT, tblschools.fldNAME AS SCHOOLNAME, tblschools.fldTOWN AS SCHOOLTOWN, tblselectedschools.fldSalutation AS SALUTATION, tblselectedschools.fldemail, tblselectedschools.fldRecordID FROM tblschools RIGHT JOIN tblselectedschools ON tblschools.fldSCHOOL_ID = tblselectedschools.fldSCHOOL_ID WHERE tblselectedschools.fldUserID = " & UserID & _
" AND tblselectedschools.fldSelected = 1 AND TRIM(tblselectedschools.fldemail) <>''"
'response.Write strSQL
'response.end

Set myRS = Connection.Execute(strSQL)

NumberSent = 0
NumberNotSent = 0

Do While Not myRS.EOF

RecordID = myRS.Fields("fldRecordID")
'Mail.AddRecipient myRS.Fields("fldContact"), myRS.Fields("fldemail")
'BodyText = strHeader & myRS.Fields("CONTACT") & "<br>" & myRS.Fields("SCHOOLNAME") & "<br>" & myRS.Fields("SCHOOLTOWN") & _
BodyText = "<br><br>" & myRS.Fields("SALUTATION") & "<br><br>" & EmailText & "</BODY></HTML>"

Mail.Body = BodyText
Mail.AddAddress myRS.Fields("fldemail"), FullLoginName
'Try to send the message
Mail.Send


'If there is an error, print it out, if the message sends ok, show success!
If Err <> 0 Then ' error occurred
    'response.write("Message Error: " & Err.Description)
   NumberSent=NumberNotSent+1
   Emails.txtEmailsNotSent.Value= NumberSent

else
   'Label1.Value="Email sent to: " & myRS.Fields("fldemail")
   'Label1.Value = "<font color=RED> " & Label1.Value & "</font>"
   NumberSent=NumberSent+1
   Emails.txtEmailsSent.Value= NumberSent
 'response.write("Your Message has been sent!")
End If



myRS.MoveNext()
Loop

strSQL = "DELETE FROM tblselectedschools WHERE tblselectedschools.fldUserID = " & UserID & _
" AND tblselectedschools.fldSelected = 1 AND TRIM(tblselectedschools.fldemail) <>''"
Connection.Execute strSQL
strSQL = "SELECT COUNT(*) AS REMAINING FROM tblselectedschools WHERE tblselectedschools.fldUserID = " & UserID & _
" AND tblselectedschools.fldSelected = 1"
Set myRS=Connection.Execute(strSQL)
NumberRemaining=myRS("REMAINING")

Connection.Close
Set Connection = Nothing
On Error Goto 0

'response.Write NumberRemaining
'response.end
If CInt(NumberRemaining)>0 Then
response.Redirect "SchoolsMailMerge.asp"
Else
response.Redirect "Home.asp"
End If


How can I adapt this so that each recipient only sees their own email address
Start Free Trial
[+][-]04.20.2008 at 11:25AM PDT, ID: 21397092

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.21.2008 at 08:49AM PDT, ID: 21403137

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.21.2008 at 09:22AM PDT, ID: 21403472

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.21.2008 at 10:39AM PDT, ID: 21404161

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.21.2008 at 10:54PM PDT, ID: 21408355

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.21.2008 at 11:02PM PDT, ID: 21408381

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.23.2008 at 03:34AM PDT, ID: 21419080

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.24.2008 at 06:55AM PDT, ID: 21430835

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.24.2008 at 08:05AM PDT, ID: 21431681

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.26.2008 at 08:11PM PDT, ID: 21447987

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Visual Basic.Net
Tags: ASP / VBScript, IE6/Mozilla
Sign Up Now!
Solution Provided By: Frosty555
Participating Experts: 1
Solution Grade: A
 
 
[+][-]04.27.2008 at 03:23AM PDT, ID: 21448686

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.01.2008 at 12:22PM PDT, ID: 21481740

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628