Пример #1
0
        public static Boolean SendEmailToUsers(String message, String destinationEmail, String subject)
        {
            Boolean sent = false;

            try
            {
                SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");

                SmtpServer.UseDefaultCredentials = false;
                SmtpServer.Port        = 587;
                SmtpServer.EnableSsl   = true;
                SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", DecryptUtil.Decrypt("ZTLLdT2lYgXkuSRUtob7aw=="));
                SmtpServer.Timeout     = 10000;

                //Specify the e-mail sender
                MailAddress from = new MailAddress("*****@*****.**",
                                                   "VideoproiectieBSCJ");

                MailAddress to = new MailAddress(destinationEmail);


                //Compose email
                MailMessage mailContent = new MailMessage(from, to);
                mailContent.Body       = TemplateHTML.BuildHTMLTemplateForUsers("VideoproiectieBSCJ", message);
                mailContent.Subject    = subject;
                mailContent.IsBodyHtml = true;

                //mailContent.CC.Add(carbonCopy);



                SmtpServer.Send(mailContent);
                SmtpServer.Dispose();
                mailContent.Dispose();
                sent = true;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(sent);
        }
Пример #2
0
        public static void SendEmailToAdministrator(String message, String subject)
        {
            try
            {
                SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");

                SmtpServer.UseDefaultCredentials = false;
                SmtpServer.Port        = 587;
                SmtpServer.EnableSsl   = true;
                SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", DecryptUtil.Decrypt("ZTLLdT2lYgXkuSRUtob7aw=="));


                //Specify the e-mail sender
                MailAddress from = new MailAddress("*****@*****.**",
                                                   "VideoproiectieBSCJ");

                string      destinationEmail = "*****@*****.**";
                MailAddress to = new MailAddress(destinationEmail);


                //Compose email
                MailMessage mailContent = new MailMessage(from, to);
                mailContent.Body       = TemplateHTML.BuildHTMLTemplate("VideoproiectieBSCJ", message);
                mailContent.Subject    = subject;
                mailContent.IsBodyHtml = true;

                //mailContent.CC.Add(carbonCopy);



                SmtpServer.Send(mailContent);
                SmtpServer.Dispose();
                mailContent.Dispose();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
        }