Example #1
0
    public static void sendAdministratorAlert(string abstractID)
    {
        Functionality fn             = new Functionality();
        DataSet       ds             = fn.GetDatasetByCommand("select * from UploadPoster where abstractID='" + abstractID + "'", "UploadPoster");
        DataTable     dt             = ds.Tables[0];
        string        abstractId     = abstractID;
        string        posterAuthor   = dt.Rows[0]["posterAuthor"].ToString();
        string        posterTitle    = dt.Rows[0]["posterTitle"].ToString();
        string        Email          = dt.Rows[0]["email"].ToString();
        string        posterCategory = dt.Rows[0]["posterCategory"].ToString();

        Alpinely.TownCrier.TemplateParser     tm      = new Alpinely.TownCrier.TemplateParser();
        Alpinely.TownCrier.MergedEmailFactory factory = new Alpinely.TownCrier.MergedEmailFactory(tm);
        string template    = HttpContext.Current.Server.MapPath("~/template/adminAlert.html");
        var    tokenValues = new Dictionary <string, string>
        {
            { "author", posterAuthor },
            { "poster", abstractID },
            { "title", posterTitle },
            { "category", posterCategory },
            { "email", Email }
        };
        MailMessage message = factory
                              .WithTokenValues(tokenValues)
                              .WithHtmlBodyFromFile(template)
                              .Create();

        message.From = new MailAddress("*****@*****.**", "IDA2013");
        message.To.Add(new MailAddress("*****@*****.**"));
        message.CC.Add(new MailAddress("*****@*****.**"));
        message.Bcc.Add(new MailAddress("*****@*****.**"));
        SmtpClient emailClient = new SmtpClient("smtp.gmail.com");

        System.Net.NetworkCredential SMTPUserInfo = new System.Net.NetworkCredential("*****@*****.**", "c0rpm41l");
        emailClient.UseDefaultCredentials = false;
        emailClient.EnableSsl             = true;
        emailClient.Credentials           = SMTPUserInfo;
        emailClient.Send(message);
    }