hi, I have created a page that sends an email to some recipients via an external SMTP
Sending works correctly!
I would like to put a progress bar that shows the status of the operation.
I have a “inviaemail” Server Connect for send.
I set up a modal with a bar whose progress bar is connected to “sendemail.executing”, but the bar doesn’t move. What I’m doing wrong?
I’ve been working on it for several days but I can’t reach the goal.
I changed my API “Inviaemail” because it seems fairer to me.
I also read the tutorials you reported to me
Despite all my attempts … nothing
The emails are sent so the ‘Repeat’ works, but the bar doesn’t scroll.
I’m doing something wrong, simple maybe, but I need your help. Thank you!
The alternative is that you have an array of recipients locally and use a flow to repeat through it, calling the server connect to send each mail. On success/error add the ID to success/error array that you then use to work out how many have been processed.
I'm already doing that. Some sendings are even 400-500 emails, the time is still short but I still wanted to try to provide more precise feedback to the user
The only other old fashion way possible will be the set a $_SESSION variable with the progress in your loop and then have a separate server action for just outputting the same session variable.
The on your page you can use the action scheduler to refresh the progress stations every half second or.
The action scheduler shouldn’t run automatically of course but you should start it when the mail send starts and stop it when it is done. So use tge onstart and on success events of the server action.
And just bind the progress value somewhere on your page.
I tried a solution like this:
at each email I read the value index + 1 and update a database field (1)
(The database is updated successfully)
I create a query to read the value of this “counter” field
Through a Server Connect “counter” I read the value
The Server Connect “counter” is activated through an action schedule (which does not start automatically, but after pressing the “send email” button).
The schedule does the connect server load operation every 10 milliseconds
In the email sending window, now have a spinner, I would like to display the loading bar or even just the number of the counter obtained from the connect server.
I don’t understand where I’m wrong.
The “counter” field is updated correctly.
The emails sent correctly.
Why can’t I at least see the value of the field change in the window? ( the best solution would be the percentage bar).
If in Edge I open the Console and enter dmx.app.data I see the values.
But when the button is clicked and the send email command (‘inviaemail’) is executed (‘modal1’ opens) then the console is refreshed and I exit dmx.app.data so i can’t see the values
I put the resolution to my problem, should anyone ever need it
first I get the number of addresses to send the message to (addresses.count)
So through “repeat”, I send the messages.
At the start of sending I set a counter value (“contatore”) which is $ index + 1; after sending mail I update a field in the “counter” table with this value.
The value increments each time by one unit and updates the table step by step
In the progress page, I get the counter number from the table I mentioned earlier filtering by ID of the message.
With an Action Scheduler set to 300 milliseconds I update the reading query.
When all emails have been sent, the Action Scheduler stops.
This action schedule is done inside a page with a Dynamic Modal, which tells the user to wait. It cannot be closed. Only at the end of the process there’s a button to close