Limit monthly emails

I’m creating an app to send emails to a mailing list, and I would like the user to be able to send only one email to their list every 30 days, , so I would like a banner to appear if he sent an email less than 30 days ago can anyone help me?

This sounds like a perfect Toast application.

When the user sends an email, set the value of the user’s lastEmailSent (this is a new field you need to add to your User table) to the current date.

When the page opens:

  • display a Toast popup saying they already sent their email for now IF their lastEmailSent is less than 30 days from the current date.
  • display a Toast popup saying they can now send another email for now IF their lastEmailSent is >= 30 days from the current date.

You can also do the same thing with a simple Alert shown at the top of the page. But I have a personal preference for how Toast notifications look vs. Alert bars.

Hope this helps.

“IF their lastEmailSent is >= 30 days from the current date” How could I do that?

Here is an example of how I change a button based on the date of the last email sent.

Assume today is October 2 and the date I selected in going to be your last email sent date.

Because 30 days haven’t elapsed, my button says “not yet”.

But in this example, enough time HAS passed:

I change the button text based on these conditions:

This is a very simplified way of doing what you want, but it should be enough to let you get started on how you want your page to work.

With this solution I prevent the user from sending emails before one month from the current date, but I am interested that if the user has already sent an email, for example 15 days ago, I can tell him that he has to wait. I also don’t care about scheduling emails, I want the user to send them immediately

You should be able to adapt my little example to do what you want. The biggest takeaway from it is that it shows you how to calculate the number of days between one date and another, which is more or less the key to what you want to do.

This topic was automatically closed after 70 days. New replies are no longer allowed.