Microsoft
Software
Hardware
Network
Question : Sending multiple emails
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(CCGetUser
ID(), 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("Persi
ts.MailSen
der")
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 = "
[email protected]
"
'Mail.From = "matthewo'gorman@lifechari
ty.org.uk"
'Mail.FromName = FullLoginName
Mail.FromName = "Matthew O'Gorman, LIFE London"
Mail.Subject = "LIFE talks"
strHeader = " " & _
""
'EmailText & ""
'Mail.Body = strFinalMsg
'Specify of the message is plain text or HTML
Mail.IsHTML = True
strSQL = "SELECT tblselectedschools.fldCont
act AS CONTACT, tblschools.fldNAME AS SCHOOLNAME, tblschools.fldTOWN AS SCHOOLTOWN, tblselectedschools.fldSalu
tation AS SALUTATION, tblselectedschools.fldemai
l, tblselectedschools.fldReco
rdID FROM tblschools RIGHT JOIN tblselectedschools ON tblschools.fldSCHOOL_ID = tblselectedschools.fldSCHO
OL_ID WHERE tblselectedschools.fldUser
ID = " & UserID & _
" AND tblselectedschools.fldSele
cted = 1 AND TRIM(tblselectedschools.fl
demail) <>''"
'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") & "
" & myRS.Fields("SCHOOLNAME") & "
" & myRS.Fields("SCHOOLTOWN") & _
BodyText = "
" & myRS.Fields("SALUTATION") & "
" & EmailText & "