Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:

C#
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();
            }
        }
    }
Posted

 
Share this answer
 
Comments
Sandeep Mewara 23-Dec-11 14:31pm    
OP is not asking on how to send an email from a web app. He is able to send the emails. He was asking on how he can add the link of last quiz!
but I don't know how to include the link of last created quiz in this email.
Best would be to add one DateTime field in the DB in the Quiz table that keeps track of the date n time of when the quiz was created.
If you don't want to do this, then you can try to get the MAX QuizID and use that as the flag to find last quiz created.
Just retrieve the latest quiz details based on datetime or id and share across the same in an email.
 
Share this answer
 
Comments
matrix388 23-Dec-11 14:33pm    
Could you please provide me with the code that includes the part of link to the last created quiz?
By the way, I am using Windows Task Scheduler for sending daily emails with the links to the daily created quizzes.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900