This topic is locked
[SOLVED]

 Send One E-mail To Users If Are =1

3/14/2014 10:05:09 AM
ASPRunnerPro General questions
G
gonzalosb author

Hi All,

i need to send one email to everyone from "E-mail List" where "E-mail Selected" is set to "1", get all the contact emails on one email
thanks for your help.

G
gonzalosb author 3/17/2014

Ok, maybe look for work around.

How about a function on list page that get all the emails of the users that "E-mail Selected" have a "Checkbox=1" all together and update a record named "ForClients" in "EmailSettings" table like:
table="EmailSettings"

EmailName - EmailList

ForEmployees - test@test.com,you@you.com,me@me.com

ForClients - client1@client1.com,client2@client2.com,client3@client3.com

G
gonzalosb author 5/9/2014

i found this code on the manual page email_to_selected_users but give me an error that says " no email found, you need to have at least 1 email", but i have 7 emails on the database.

here is how i have it setup to select the email witch "E-mail Selected = 1":

response.Flush

dim arr,record, email_list, rmail, arr2, where, errmsg, ret

currentTable = ""
email_list=""

set rmail=CreateDictionary()

DoAssignment record, button.getNextSelectedRecord()

do while isObject(record)

arr=split(record("[color="#FF0000"]ID"),"&")

if asp_count(arr)>=0 then

set arr2=CreateDictionary()

arr2("")=asp_urldecode(arr(0))

where = KeyWhere(arr2,"")

set data = dal.Table(currentTable).Query(where,"")

if data("[color="#FF0000"]E-mail Selected")<>"" then

email_list=email_list & data("[color="#FF0000"]E-mail") & ","

end if

data.close

set data=nothing

end if

DoAssignment record, button.getNextSelectedRecord()

loop

if email_list<>"" then

email_list = left(email_list,len(email_list)-1)

end if


the same information works with the one that send a mass email to all the emais on the list,(email to all) that means the information is correct:



Response.Flush

set data = dal.Table("").QueryAll()

while not data.eof

' send the email

rmail("to")=data("[color="#FF0000"]E-mail")



any ideas?
thanks

G
gonzalosb author 5/22/2014

More than 300 views and no one have a solution for this?

Sergey Kornilov admin 5/22/2014

Providing a solution just looking at your code is not possible. You have to run this code, check for errors, print some variables to see what is happening etc.
If you need help with this post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL. 'Demo Account' button can be found on the last screen in the program.

G
gonzalosb author 6/13/2014

Here is the correct code to send if EmailSelected=1
this code will send the email to every one by separated

this one is good be use for news or updates emails where no want to show how else receive it



Response.Flush

set data = dal.Table("YourTable").Query(where,"EmailSelected=1")

while not data.eof
' send the email

rmail("to")=data("email")

rmail("subject")="Sample subject"

rmail("body")="Sample body"

set result = runner_mail(rmail)

' if error happened print a message on the web page
if not result("mailed") then

response.write result("message") & "
"

response.flush

end if
data.MoveNext

wend

data.close: data=nothing


this code will send the email all together and all the addresses will be shown at the "send to" for everybody.

this one is good be use for team emails where the reply is send to everyone



Response.Flush

set data = dal.Table("YourTable").Query(where,"EmailSelected=1")

while not data.eof

data.MoveNext

wend

data.close: data=nothing
' send the email

rmail("to")=data("email")

rmail("subject")="Sample subject"

rmail("body")="Sample body"

set result = runner_mail(rmail)

' if error happened print a message on the web page
if not result("mailed") then

response.write result("message") & "
"

response.flush

end if


please coment if this help you, thanks