如何在电子邮件中将链接放置到系统中最后创建的测验? [英] How to put the link to the last created quiz in the system in the emails?

查看:111
本文介绍了如何在电子邮件中将链接放置到系统中最后创建的测验?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新的ASP.NET开发人员.我需要开发Web应用程序,以便能够每天早上7点自动发送电子邮件.我知道如何使用Windows Task Scheduler做到这一点.我需要做的就是创建一个包含脚本的页面,该脚本向数据库中的所有用户发送电子邮件,并链接到数据库中最后一个测验.
表的架构:

**员工表:用户名,名称,职位,电子邮件**

**测验表:QuizID,标题,说明**

**问题表:QuestionID,Question,Answer1,Answer2,Answer3,CorrectAnswer,QuestionOrder,QuizID.**

现在,我可以通过创建一个页面来发送电子邮件,该页面在Page_load方法中包含发送电子邮件所需的代码,但但我不知道如何在此电子邮件中包括上次创建的测验的链接.该怎么做?
我的后台代码是:

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

推荐答案

检查此博客
http://www.daniweb.com/web-development/aspnet/threads/51587 [ ^ ]
--NDK
check this blog
http://www.daniweb.com/web-development/aspnet/threads/51587[^]
--NDK


,但我不知道如何在此电子邮件中包含最近创建的测验的链接.
最好是在测验表的数据库中添加一个DateTime字段,以跟踪创建测验的日期和时间.
如果您不想这样做,则可以尝试获取MAX QuizID并将其用作标记以查找创建的最后一个测验.
只需根据日期时间或id检索最新的测验详细信息,然后在电子邮件中共享它们即可.
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.


这篇关于如何在电子邮件中将链接放置到系统中最后创建的测验?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆