This topic is locked

send mass email from table

1/31/2007 5:23:44 PM
ASPRunnerPro General questions
S
SteveL author

i have two tables. One of the tables just stores email addresses. How do I use the send email event to include all email addresses in the "email" field?
ie:
Function BeforeAdd(dict)
Dim keys

message =""
keys = dict.keys

For n = 0 To dict.Count-1

message = message & keys(n) & " : " & dict(keys(n)) & vbcrlf

Next
email="email field" <----****i want to include all email addresses from my email table

subject="New data record"
sendmail email, subject, message
BeforeAdd = True
' set BeforeAdd to True if you like to proceed with adding new record

' set it to False in other case
thanks
End Function

J
Jane 2/1/2007

Here is a sample code to pull all emails from the EmailTable:

str = "select Emailfield from EmailTable"

Set rsTemp = server.CreateObject("ADODB.Recordset")

rsTemp.open str, dbConnection

all_emails = ""

while not rsTemp.eof

all_emails = all_emails & rsTemp("EmailField") & ", "

rsTemp.movenext

wend

all_emails = Left(all_emails,len(all_emails)-2)



where EmailField is your actual field name, EmailTable is your actual table name.
Then use all_emails variable as email in the sendmail function.

lefty 2/9/2007

Here is a sample code to pull all emails from the EmailTable:

where EmailField is your actual field name, EmailTable is your actual table name.
Then use all_emails variable as email in the sendmail function.



I tried the same code ; The sendmail function errored with must select a domain extension. The varible all_emails seems right but program thinks it needs @.test at the end; which shows me that it is not getting the fldemail from the database ans is trying to send the variable "all_emails" . any help would be highly appreciated as we are trying to design a mass newsletter project. thanks

lefty 2/13/2007



I tried the same code ; The sendmail function errored with must select a domain extension. The varible all_emails seems right but program thinks it needs @.test at the end; which shows me that it is not getting the fldemail from the database ans is trying to send the variable "all_emails" . any help would be highly appreciated as we are trying to design a mass newsletter project. thanks



Has anyone come up with a solution to the above ; it would be appreciated.?

J
Jane 2/15/2007

John,
try to print all_emails variable on the page and post resulting string here:

response.write all_emails