事件开始前一天发送提醒电子邮件

问题描述 投票:0回答:1

我正在尝试了解如何在活动开始前一天向用户发送提醒电子邮件,例如:有一个事件将开始:03-02-2020和我想在前一天发送提醒:02-02-2020

她是我的查询内容:

  var RegistrtionToEvent = db.Registrations
                .Where(t => (t.LastNotifiedDate == null) && t.Status == "signedup" &&
                 t.EventStartDate //here is my problem what it should be done here with EventStartDate)
                .ToList();

            if (RegistrtionToEvent != null && RegistrtionToEvent.Any())
            {
                foreach (var item in RegistrtionToEvent)
                {

                        item.LastNotifiedDate = DateTime.Now;
                        //sending Email

                }
                db.SaveChanges();
            }

谁能帮我! :)谢谢

c# entity-framework
1个回答
0
投票

如果Tommorrow是活动日,您将发送电子邮件

var today = DateTime.Today;
var notifyDay = t.EventStartDate.AddDays(-1);

 var RegistrtionToEvent = db.Registrations
                    .Where(t => (t.LastNotifiedDate == null) && t.Status == "signedup" &&
                     notifyDay == today) //here is my problem what it should be done here with EventStartDate)
                    .ToList();
© www.soinside.com 2019 - 2024. All rights reserved.