This topic is locked

Send Email With Data From List and View Page

11/11/2013 10:49:41 AM
ASPRunnerPro General questions
G
gonzalosb author

ASPR 7.2 MS database
hi,

i have a button on List and View pages that send hardcoded e-mails just fine but I don't found the way to incorporate the existing fields information on it.

for example this works...
email="info@test.com"

subject="Email from website"

email_msg="this is a test"

Sendmail email,subject,mail_msg
I want to add on "email_msg=" the values of the fields COLOR , SHAPE# , TYPE on List and on View page.
Thank you in advance.

Sergey Kornilov admin 11/11/2013

http://xlinesoft.com/asprunnerpro/docs/inserting_button.htm

Example 2 explains how to access values of selected record.

G
gonzalosb author 11/11/2013

i try that, actually the code im using is from that page using the example # 2 but it looks like that code is not completlly coorect because on the example use "sendmail(email,etc)" when is " sendmail email, etc" without "()" so i dont know what else can be wrong.

i try the rest of the code and nothing happens, not send or error display.

Sergey Kornilov admin 11/11/2013

Try to find if button's code produces any errors. Check this article and post results here:

http://xlinesoft.com/asprunnerpro/docs/troubleshooting_custom_buttons.htm

G
gonzalosb author 11/13/2013

found few problems.
1)

example 2 use

DoAssignment record, button.getNextSelectedRecord()



even if the button is inserted on the row you need to select the same row by using the checkmark, so this code is good for use as a single button on top instead of in the datagrid witch will be good idea to be specify on the manual.

i velieve for datagrid button needs to be use "rowData.fields" witch is explain in rowdata_object but i dont know how.
2)

as i say before on this topic the code on the manual use "sendmail(email,etc)" when is " sendmail email, etc" , without "()"
3)

the code use

"\r\n"

what i believe is PHP phrase and not ASP so is not doing the function it suppose to but i can not found a substitution for ASP for this code

i try:


</br>

<br/>



with and without "<>"

G
gonzalosb author 11/14/2013
  1. how can i replace getNextSelectedRecord() with getCurrentRecord() or ROWDATA on this codeto be use on View page?

email_msg= "List of records"

i=1

DoAssignment record, button.getNextSelectedRecord()

do while isObject(record)

email_msg=email_msg & "Record: " & i & "\r\n"

email_msg=email_msg & "Name: " & record("name") & "\r\n"

email_msg=email_msg & "Lastname: " & record("lastname") & "\r\n"

email_msg=email_msg & "\r\n"

DoAssignment record, button.getNextSelectedRecord()

i=i+1

loop

'send email

email = "test@test.com"

subject = "Sample subject"

sendmail(email,subject,email_msg)


Ohh, and by the way, in orther to work properly on ASP, "\r\n" needs to be replace with VBCRLF without ""
2) how can i make this email be HTML? it put symbols instead of accented letters= "Jes�s Gonz�lez"

Sergey Kornilov admin 11/14/2013
G
gonzalosb author 11/14/2013



On sending HTML email:

http://xlinesoft.com/asprunnerpro/docs/runner_mail_function.htm



ok.. as you show me i need to use tmpDict code to be HTML as the code i post before is only PlainText

so now im using

dim tmpDict
set tmpDict = CreateObject("Scripting.Dictionary")
tmpDict("to")="test@test.com"
tmpDict("subject")="Sample subject"
tmpDict("body")="Hello there" & vbcrlf & "Best regards"
runner_mail tmpDict


and no more symbols !!!
now how can i get to send info from the View page on the email?

Sergey Kornilov admin 11/15/2013

I'm afraid I don't follow. How do you want to send that email from the View page? Are you talking about adding a button there?

G
gonzalosb author 11/19/2013

OK!! i have it almost solve!!!

first of all i need to clarify that on "runner_mail tmpDict" only on 7.2ASPR works without "()" but on 8.0ASPR need to be use.

ok here is the simplest email sender with DATA from the table in use, View or List page, useing HTML.



'Look for data on CURRENT table
set rstmp = dal.table(strTableName).QuerryAll()

Subject = data("Title")

b1 = data("color")

b2 = data("model")

userlist = ("userlist")

rstmp.close
'Send the e-mail
dim tmpDict

set tmpDict = CreateObject("Scripting.Dictionary")

tmpDict("to") = "test@test.com"

tmpDict("subject") = Subject

tmpDict("htmlbody") = "The color is " & b1 & "and model " & b2 & "selected by " & userlist & "
" & "have a good day !!!"

runner_mail tmpDict


Now here is the new problem...
in the view page i use a code to separate the names one on top of the other instead of "name,name,name"

strValue = replace(strValue, ",", "
")



can be something like this be add on the " userlist = ("userlist") " to do the same on the email?
thank you
PS: diferent body type use diferent coding, for example:



body: vbcrlf

htmlbody: <"br">