示例#1
0
        public void sendMail()
        {
            MailMessage mail = new MailMessage();
            SmtpClient  smtp = new SmtpClient();

            GeneralMethod.createZipFile();
            string fromEmail    = ConfigurationManager.AppSettings["FromEmail"];
            string fromPassword = ConfigurationManager.AppSettings["FromPassword"];

            try
            {
                ContentType ctype   = new ContentType("application/zip");
                string      zipFile = GeneralMethod.GetZipFolderPath() + @"\ExtentReport.zip";
                mail.From = new MailAddress(fromEmail, "Testingxpters");
                mail.To.Add(new MailAddress("*****@*****.**", "Testingxperts"));
                mail.To.Add(new MailAddress("*****@*****.**", "Testingxperts"));
                mail.Subject = "Automation Test Reports";
                mail.Body    = "Hi \n\n Please find the reports attached.\n\n Regards \n Testingxperts";
                mail.Attachments.Add(new Attachment(zipFile, ctype));
                smtp.Host                  = "smtp.gmail.com";
                smtp.Port                  = 25;
                smtp.EnableSsl             = true;
                smtp.UseDefaultCredentials = false;
                smtp.Credentials           = new System.Net.NetworkCredential(fromEmail, fromPassword);
                smtp.Send(mail);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.ReadLine();
            }
        }
示例#2
0
        public void Zip()
        {
            GeneralMethod.createZipFile();
            int portNumber = Convert.ToInt32(ConfigurationManager.AppSettings["Port"]);

            try
            {
                ContentType ctype   = new ContentType("application/zip");
                string      zipFile = GeneralMethod.GetZipFolderPath() + @"\ExtentReport.zip";
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.ReadLine();
            }
        }
示例#3
0
        public void sendMail()
        {
            MailMessage mail = new MailMessage();
            SmtpClient  smtp = new SmtpClient();

            GeneralMethod.createZipFile();
            string fromEmail    = ConfigurationManager.AppSettings["FromEmail"];
            string fromPassword = ConfigurationManager.AppSettings["FromPassword"];
            string smtpHost     = ConfigurationManager.AppSettings["SMTPHost"];
            int    portNumber   = Convert.ToInt32(ConfigurationManager.AppSettings["Port"]);

            try
            {
                ContentType ctype   = new ContentType("application/zip");
                string      zipFile = GeneralMethod.GetZipFolderPath() + @"\ExtentReport.zip";
                mail.From = new MailAddress(fromEmail, "TestingXperts");
                mail.To.Add(new MailAddress("*****@*****.**", "rajbir"));
                mail.To.Add(new MailAddress("*****@*****.**", "TestingXperts"));
                mail.Subject    = "Automation Test Reports";
                mail.IsBodyHtml = true;
                body            = PopulateBody();
                mail.Body       = body.ToString();
                mail.Attachments.Add(new Attachment(zipFile, ctype));
                smtp.Host                  = smtpHost;
                smtp.Port                  = portNumber;
                smtp.EnableSsl             = true;
                smtp.UseDefaultCredentials = false;
                smtp.Credentials           = new System.Net.NetworkCredential(fromEmail, fromPassword);
                smtp.Send(mail);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.ReadLine();
            }
        }