Hello All,
I've been using the following code for a couple of years since Stan Matthews very kindly helped me with it. I've also been using it in Windows 8 for a year with no problems. Just last week I ran the code which is to send an account report in pdf format to 30 customers via email. Everything else in the database works perfectly but now it sends some reports that say 'No record found' but according to our clients, the data is actually sent to the email address in the customer table. Even then it stops after about 23 to 25 sends.
The records sent return true. I'm thinking that a recent upgrade in W8 has caused this. When I had similar problems last year I got lots of help from the forum and eventually solved it by installing the Amyuni printer driver but this is in the directory now and seems to have all of it's files. If I try to send just one account report now, the pdf is created but contains all of the 30 records in one pdf.
Any pointers would be really appreciated, here is the code;
'Date Created: 19-Oct-2013 03:07:47 PM
'Last Updated: 27-Nov-2017 11:46:46 AM
'Created By : Stan Matthews
'Updated By : Laura
'dim rslt as n
parentform.commit()
tbl = table.current()
tbl.fetch_first()
while .not. tbl.fetch_eof()
query.filter = "cuscode = "+quote(alltrim(tbl.cuscode)) + " .and. (.not. sent)"
query.order = ""
to_param = Lookup("Customers","cuscode = "+quote(alltrim(tbl.cuscode)),"alltrim(email)")
if alltrim(to_param) > "" .or. (.not. (tbl.sent))'only execute this section if an email address is not found OR 'sent' is not logical true
cc_param = a5_eval_expression("",local_variables())
bcc_param = a5_eval_expression("[email protected]",local_variables())
subject_param = "Monthly account from Laprima S.L."
message_param = "Your attached account covers the month of "+cmonth(date())+"."
if filefind.get(a5.Get_Path()+chr(92)+"Accounts "+cmonth(date()),FILE_FIND_DIRECTORY,"PN") = ""
dir_create(a5.Get_Path()+chr(92)+"Accounts "+cmonth(date()))
end if
:report.SaveAs("AccMonthly","PDF",query.filter,query.order,a5.get_path()+chr(92)+"Accounts "+cmonth(date())+chr(92)+"Acct "+tbl.cuscode+".pdf")
sleep(2)
rslt = email_send(to_param,subject_param,message_param,a5.get_path()+chr(92)+"Accounts "+cmonth(date())+chr(92)+"Acct "+alltrim(tbl.cuscode)+".pdf","",bcc_param)
sleep(6)
if rslt = 1 'email_send() result for good send is 1
tbl.change_begin()
tbl.sent = .t.
tbl.change_end(.T.)
end if
end if 'end of section to create and send email if address found
tbl.fetch_next()
end while
fil.flush()
fil.close()
Thanks,
Trevor.
I've been using the following code for a couple of years since Stan Matthews very kindly helped me with it. I've also been using it in Windows 8 for a year with no problems. Just last week I ran the code which is to send an account report in pdf format to 30 customers via email. Everything else in the database works perfectly but now it sends some reports that say 'No record found' but according to our clients, the data is actually sent to the email address in the customer table. Even then it stops after about 23 to 25 sends.
The records sent return true. I'm thinking that a recent upgrade in W8 has caused this. When I had similar problems last year I got lots of help from the forum and eventually solved it by installing the Amyuni printer driver but this is in the directory now and seems to have all of it's files. If I try to send just one account report now, the pdf is created but contains all of the 30 records in one pdf.
Any pointers would be really appreciated, here is the code;
'Date Created: 19-Oct-2013 03:07:47 PM
'Last Updated: 27-Nov-2017 11:46:46 AM
'Created By : Stan Matthews
'Updated By : Laura
'dim rslt as n
parentform.commit()
tbl = table.current()
tbl.fetch_first()
while .not. tbl.fetch_eof()
query.filter = "cuscode = "+quote(alltrim(tbl.cuscode)) + " .and. (.not. sent)"
query.order = ""
to_param = Lookup("Customers","cuscode = "+quote(alltrim(tbl.cuscode)),"alltrim(email)")
if alltrim(to_param) > "" .or. (.not. (tbl.sent))'only execute this section if an email address is not found OR 'sent' is not logical true
cc_param = a5_eval_expression("",local_variables())
bcc_param = a5_eval_expression("[email protected]",local_variables())
subject_param = "Monthly account from Laprima S.L."
message_param = "Your attached account covers the month of "+cmonth(date())+"."
if filefind.get(a5.Get_Path()+chr(92)+"Accounts "+cmonth(date()),FILE_FIND_DIRECTORY,"PN") = ""
dir_create(a5.Get_Path()+chr(92)+"Accounts "+cmonth(date()))
end if
:report.SaveAs("AccMonthly","PDF",query.filter,query.order,a5.get_path()+chr(92)+"Accounts "+cmonth(date())+chr(92)+"Acct "+tbl.cuscode+".pdf")
sleep(2)
rslt = email_send(to_param,subject_param,message_param,a5.get_path()+chr(92)+"Accounts "+cmonth(date())+chr(92)+"Acct "+alltrim(tbl.cuscode)+".pdf","",bcc_param)
sleep(6)
if rslt = 1 'email_send() result for good send is 1
tbl.change_begin()
tbl.sent = .t.
tbl.change_end(.T.)
end if
end if 'end of section to create and send email if address found
tbl.fetch_next()
end while
fil.flush()
fil.close()
Thanks,
Trevor.
Comment