MATLAB Answers

How to send email reminders using sendmail

1 view (last 30 days)
Sue MM
Sue MM on 22 Jul 2019
Commented: Sue MM on 22 Jul 2019
Hi, I’m trying to set up an email reminder system, where I can send emails at certain dates. I’ve been looking at the sendmail function but I haven’t found any information as to how I can edit the send date. I.e I have a simple csv, with email addresses and appointment reminders and want to send email reminders based on those dates.
Any help would be much appreciated!

  0 Comments

Sign in to comment.

Accepted Answer

Adam Danz
Adam Danz on 22 Jul 2019
Is that a 3rd party function or are you refering to sendmail()? It is not possible to set the send-date using sendmail(). The email is sent when the command it executed. Instead, you could write a program that could be run daily where a table contains the email information in one column and the send-date in another column. If today's date is the send date, the program could send the email and then remove the entry from the table.
Alternatively you could create a timer object that controls when the email is sent but if matlab shuts down (or if the timer object is deleted) the emails will never be sent.

  6 Comments

Show 3 older comments
Sue MM
Sue MM on 22 Jul 2019
Thank you, I really appreciate that! Using this method I can use the sendmail() correct? Also- it would be okay to say send the email 2/3 days in advance by editing the datestr(floor(now))?
Adam Danz
Adam Danz on 22 Jul 2019
"Using this method I can use the sendmail() correct?"
Yes, you can see where I call sendmail() in my for-loop. Also, here's a demo I wrote a while back.
"would be okay to say send the email 2/3 days in advance by editing the datestr(floor(now))?"
That's one way of doing it. Another way would be to subtract 3 days from the appointment day.
todayRowIdx = (datetime(c(:,2)) - days(3)) == datestr(floor(now));
% Or
todayRowIdx = datetime(c(:,2)) == (datestr(floor(now)) + days(3));
Sue MM
Sue MM on 22 Jul 2019
Amazing, I’ll give this a try thank you!!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by