Exemplo n.º 1
0
        protected void btnSendEmail_Click(object sender, EventArgs e)
        {
            int CustID;

            int.TryParse(drpCustID.SelectedValue, out CustID);
            DBcalls   db        = new DBcalls();
            DataTable datTable  = db.GetCustomerById(CustID);
            DataRow   row       = datTable.Rows[0];
            string    CustName  = row["CustName"].ToString();
            string    CustEmail = row["CustEmail"].ToString();

            spnTo.InnerText   = "TO: " + CustEmail;
            spnSubj.InnerText = "SUBJ: Thank you";
            spnBody.InnerText = "BODY: Hello " + CustName + ", thank you for using Energy Simply.";

            var apiKey           = "";
            var client           = new SendGridClient(apiKey);
            var from             = new EmailAddress(CustEmail, CustName);
            var subject          = "Thank you";
            var to               = new EmailAddress(CustEmail, CustName);
            var plainTextContent = "Hello " + CustName + ", thank you for using Energy Simply.";
            var htmlContent      = "Hello " + CustName + ", thank you for using Energy Simply.";
            var msg              = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);
            var response         = client.SendEmailAsync(msg);
        }
Exemplo n.º 2
0
        protected void btnPreview_Click(object sender, EventArgs e)
        {
            int CustID;

            int.TryParse(drpCustID.SelectedValue, out CustID);
            if (CustID > 0)
            {
                DBcalls   db        = new DBcalls();
                DataTable datTable  = db.GetCustomerById(CustID);
                DataRow   row       = datTable.Rows[0];
                string    CustName  = row["CustName"].ToString();
                string    CustEmail = row["CustEmail"].ToString();
                spnTo.InnerText   = "TO: " + CustEmail;
                spnSubj.InnerText = "SUBJ: Thank you";
                spnBody.InnerText = "BODY: Hello " + CustName + ", thank you for using Energy Simply.";
            }
            else
            {
                spnTo.InnerText   = "TO: ";
                spnSubj.InnerText = "SUBJ: ";
                spnBody.InnerText = "BODY: ";
            }
        }