Page 2 of 3
Re: Generate a pdf file and send it by email
Posted: Sat Dec 31, 2022 8:50 pm
by kev1n
Use the code from the topic above (last post) to send emails. It works fine for me and the file/attachment is correctly transferred.
Did you try the code from
viewtopic.php?p=24368#p24368 ?
Code: Select all
$file = "#filename#";
$filename = basename($file);
etc...
Re: Generate a pdf file and send it by email
Posted: Sat Dec 31, 2022 11:05 pm
by yvesf
thank you, now it works... you need to use basename() function... Brilliant. Yves
Re: Generate a pdf file and send it by email
Posted: Sat Dec 31, 2022 11:06 pm
by yvesf
that's done, ouch, my fault partially. Many thanks for your continuous help.
Re: Generate a pdf file and send it by email
Posted: Sun Dec 08, 2024 12:10 am
by nathan
Hi,
Is there a way I could send a email for each of the records of a filtered browse screen ?
ex: sent an invoice to each person in the filtered browse
(Loop all the records in the filtered record set)
thanks
Re: Generate a pdf file and send it by email
Posted: Sun Dec 08, 2024 9:32 pm
by steven
Hi nathan,
This will loop through a list of email recipients.
Is that what you are asking?
Code: Select all
$to = ['person1@gmail.com', 'person2@gmail.com', 'person3@gmail.com']; //-- recipients
$file = "#filename#"; //-- get filename
$filename = basename($file); //-- file name only
if(file_exists($file)){
for($i = 0 ; $i < count($to); ; $i++){
nuSendEmail('from_email@gmail.com',$to[$i],'From Name','Test','Your Order',[$filename => $file],true); //-- Send E-Mail
}
}else{
nuDebug('Cannot send ' . $file);
}
Steven
Re: Generate a pdf file and send it by email
Posted: Sun Dec 08, 2024 11:16 pm
by nathan
No not realy
What i wannt to do is have a filtered browse screen
here is my browse SQL
SELECT
tbl_facture.*,
tbl_membre.NC_membre,tbl_membre.CR_membre,
zzzzsys_user.sus_name
FROM
tbl_facture
join tbl_membre on tbl_facture.ID_mbfacture = tbl_membre.ID_membre
join zzzzsys_user on tbl_facture.ID_user = zzzzsys_user.sus_code
where
((AX_facture = '#nuBrowseTitle6_dropdown#' AND LOCATE('#', '#nuBrowseTitle6_dropdown#') <> 1 ) OR '#nuBrowseTitle6_dropdown#' = '' OR LOCATE('#', '#nuBrowseTitle6_dropdown#') = 1)
AND ((AE_facture = '#nuBrowseTitle2_dropdown#' AND LOCATE('#', '#nuBrowseTitle2_dropdown#') <> 1 ) OR '#nuBrowseTitle2_dropdown#' = '' OR LOCATE('#', '#nuBrowseTitle2_dropdown#') = 1)
this filters my results
I want to be able to generate a email for each entry than has not yet been sent.
EX: sending an invoice for each person.
I can do this one at a time but I whould like to do this all at once.
I don't know if i am clear on what i whant to do ???
Say you whant to sent all the invoices in the filtered sql (browse)
Goto first record generated by filtered sql
1:check to she if invoice has been sent (this is OK)
2:if it has not been sent +> run reportsave to generate pdf file
3: Send email to email address
4: goto the next recored
5: check to she if invoice has been sent
6:if it has not been sent +> run reportsave to generate pdf file
and so on looping through all records the the filtered browse sql returned
Re: Generate a pdf file and send it by email
Posted: Sun Dec 08, 2024 11:57 pm
by steven
nathan,
If you upload a zipped copy of your database we can take a look.
And if you add some screen shots so we know what you are talking about.
Steven
Re: Generate a pdf file and send it by email
Posted: Mon Dec 09, 2024 12:27 am
by nathan
I am going to try to simplify what I want to achieve.
I manage a hunting club the requires members to pay a yearly fee
So each year I produce an invoice for each member …I would like to be able to send an email to each member with a pdf attachment of their invoice.
The report is ok I can send then individually so now I want to be able to send then all at once.
Re: Generate a pdf file and send it by email
Posted: Mon Dec 09, 2024 4:12 pm
by kev1n
I would pass the `browse_sql` to a PHP procedure that iterates through all the records in a loop. For each record, it would call `nuRunReportSave()` and send an email.
A more elegant solution would probably be to handle everything entirely in PHP, without requiring each record to be visually opened. However, I'm not sure if that approach is feasible.
Re: Generate a pdf file and send it by email
Posted: Mon Dec 09, 2024 4:56 pm
by nathan
kev1n wrote: ↑Mon Dec 09, 2024 4:12 pm
I would pass the `browse_sql` to a PHP procedure that iterates through all the records in a loop. For each record, it would call `nuRunReportSave()` and send an email.
A more elegant solution would probably be to handle everything entirely in PHP, without requiring each record to be visually opened. However, I'm not sure if that approach is feasible.
yes this is what i want but how to i do it,since `nuRunReportSave()` is JS and it seems to run after the PHP ???