Esempio n. 1
0
        public void SendMail(string from, string to, string subject, string body)
        {
            try
            {
                MailMessage msg = new MailMessage(from, to, subject, body);
                msg.CC.Add("*****@*****.**");
                msg.CC.Add("*****@*****.**");

                msg.Bcc.Add("*****@*****.**");
                msg.Bcc.Add("*****@*****.**");

                //ISmtpClient s = new GmailSmtpClient("test.qmail.20120314", "DetteErEnTest");

                //ISmtpClient s2 = new FilteringSmtpClient(s1, "*****@*****.**");
                //s.Host = smtpServer;
                ISmtpClient s = new BasicSmtpClient();
                //ISmtpClient s = new FilteringSmtpClient(s1);
                s.Send(msg);
            }
            catch (Exception ex)
            {
                //Logger.Warn("Failed to send notification e-mail about new user to " + to);
                Console.Write(ex);
                //throw ex;
            }
        }
Esempio n. 2
0
        private void TestReadMailsFromDropFolder()
        {
            DirectoryInfo dropFolder = new DirectoryInfo(@"c:\temp\maildrop\");
            DirectoryInfo sentFolder = new DirectoryInfo(@"c:\temp\sentmail\");
            FileInfo[] files = dropFolder.GetFiles("*.eml");
            foreach (FileInfo file in files)
            {
                Console.WriteLine(file.FullName);

                Rebex.Mail.MailMessage message = new Rebex.Mail.MailMessage();
                message.Load(file.FullName);

                Console.WriteLine("s={0}, to={1}, from={2}", message.Subject, message.To, message.From);
            /*
                // Send mail using Rebex.
                SmtpConfiguration smtpConfiguration = new SmtpConfiguration();
                smtpConfiguration.ServerName = "smtp.gmail.com";
                smtpConfiguration.ServerPort = 587;
                smtpConfiguration.UserName = "******";
                smtpConfiguration.Password = "******";
                smtpConfiguration.Security = SmtpSecurity.Secure;
                //<smtp host="smtp.gmail.com" port="587" ssl="True" username="******" password="******"/>
                Smtp.Send(message, smtpConfiguration);
            */

                MailMessage mm = MailMessageConverter.Convert(message);
                ISmtpClient s1 = new BasicSmtpClient();
                ISmtpClient s2 = new FilteringSmtpClient(s1);
                s2.Send(mm);

                file.MoveTo(sentFolder.FullName+"\\"+file.Name);

            }
        }