I would like to use a button on a form and execute a script to create personalized reports. Each report is saved in a corresponding client directory. I 'm using a filter to select the needed records and would like to send each report to the customer by mail.
I'm not able to get it working. The script creates a report for the first record and mails the report to the customer. However the same report for the same customer and record is created and mailed over and over again. It doesn't fetch to the next record. What is missing in the script?
I'm not able to get it working. The script creates a report for the first record and mails the report to the customer. However the same report for the same customer and record is created and mailed over and over again. It doesn't fetch to the next record. What is missing in the script?
Code:
topparent.commit() tbl = table.current() tbl.fetch_first() while .not. tbl.fetch_eof() if isblank("adm_bezwaar->Bz_Uitsprk") then subject = alltrim(memo_bz->bz_C_OW_1) orgaan = alltrim(adm_bezwaar->Bz_client) number = alltrim(tbl.adm_nr) client = alltrim(tbl.clientname) base_path = "G:\clienten\\" dir_name = number+" "+client dir_create_recurse(base_path+dir_name) record_number = current_record_number() query.filter = "recno() = " + record_number query.order = "" report.saveas("bezwaarschrift", "PDF", query.filter, "",base_path+dir_name+"\\"+"brief"+SPACE(1) +orgaan+ SPACE(1) +subject+".pdf") 'Send an e- mail message using the Alpha Five e-mail clilent. if is_object(topparent.this) then form_name = topparent.name()+".this" else form_name = "" end if Dim message_type as c message_type = "" _to_var = a5_eval_expression("=ADRESSEN_CLIENT->ADR_EMAIL",local_variables()) '_to_var = a5_eval_expression("=adressen->Adr_Email",local_variables()) param_to = _to_var subject_var = a5_eval_expression("=memo_bz->bz_C_Ow_1",local_variables()) param_subject = subject_var param_cc = "" param_bcc = "" message_text = <<%a% Text text text. %a% param_message = message_text attachment_list = base_path+dir_name+"\\"+"brief"+SPACE(1) +orgaan +SPACE(1) +subject+".pdf" param_attachments = alltrim(attachment_list) 'Send the e-mail message directly - do not open the Alpha Five e-mail client send_result = email_send(param_to,param_subject,param_message,param_attachments,param_cc,param_bcc,.t.,message_type) if send_result = 1 then ui_msg_box("Notice","E-mail message sent.",UI_INFORMATION_SYMBOL) else ui_msg_box("Error","E-mail message was not sent.",UI_STOP_SYMBOL) end if else end if tbl.fetch_next() end while
Comment