Esempio n. 1
0
        public static void SendConfirmEmail(AppointmentEmail newEmail)
        {
            MailMessage msg = new MailMessage();

            System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();

            try
            {
                msg.Subject = newEmail.EmailSubject;
                msg.Body    = newEmail.EmailContent;
                msg.From    = new MailAddress("*****@*****.**");
                msg.To.Add(newEmail.CustomerEmail);

                msg.IsBodyHtml = true;
                client.Host    = "smtp.gmail.com";
                System.Net.NetworkCredential basicauthenticationinfo = new System.Net.NetworkCredential("*****@*****.**", "1142311423");

                client.Port                  = int.Parse("587"); //if using SSL 465
                client.EnableSsl             = true;
                client.UseDefaultCredentials = false;
                client.Credentials           = basicauthenticationinfo;
                client.DeliveryMethod        = SmtpDeliveryMethod.Network;
                client.Send(msg);
            }
            finally
            {
            }
        }
Esempio n. 2
0
        public void sendConfirmEmail_Click(object sender, EventArgs e)
        {
            Thisemail = email.Text;

            subject = "Appointment Confirmation for " + fname.Text;

            content = @"<h2 style='color: blue; '> Hello " + fname.Text + " ," + " the following appointment has been booked for you: </h2> " + "<br>" +
                      details.Text;


            AppointmentEmail newemail = new AppointmentEmail(subject, content, Thisemail);

            try
            {
                ConnectionClass.SendConfirmEmail(newemail);
                Response.Write("<script type='text/javascript'>");
                Response.Write("alert('Appointment Confirm Email Sent Successfully! ');");
                Response.Write("</script>");
            }

            catch
            {
                Response.Write("<script type='text/javascript'>");
                Response.Write("alert('Sending Email Failed ');");
                Response.Write("</script>");
            }
        }