I am a new ASP.NET developer. I need to develop the web application to be able to send emails automatically everyday at 7am. I know how to do that using Windows Task Scheduler. All what I need to do is creating a page that contains a script which send emails to all users in the database with link to the last created quiz in the database.
The schema of the tables:
**Employee Table: Username, Name, Job, Email**
**Quiz Table: QuizID, Title, Description**
**Question Table: QuestionID, Question, Answer1, Answer2, Answer3, CorrectAnswer, QuestionOrder, QuizID.**
Now, I could be able to send emails by creating a page that contains the required code for sending email in the Page_load method,
but I don't know how to include the link of last created quiz in this email. How to do that?
My Code-Behind is:
protected void Page_Load(object sender, EventArgs e)
{
SmtpClient sc = new SmtpClient("mail address");
MailMessage msg = null;
try
{
msg = new MailMessage("xxxx@gmail.com",
"yyyy@gmail.com", "Message from PSSP System",
"This email sent by the PSSP system");
sc.Send(msg);
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (msg != null)
{
msg.Dispose();
}
}
}