Esempio n. 1
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);

            }
        }
Esempio n. 2
0
        private StoredMailMessage LoadMailFromFile(FileSystemInfo first)
        {
            // load mail
            FileInfo file = new FileInfo(first.FullName);
            string fileNameLoading = first.FullName + ".loading";
            file.MoveTo(fileNameLoading);

            Rebex.Mail.MailMessage rmessage = new Rebex.Mail.MailMessage();
            rmessage.Load(fileNameLoading);

            file.MoveTo(first.FullName + ".loaded");

            StoredMailMessage mm = new StoredMailMessage(first.Name);
            MailMessageConverter.ConvertTo(rmessage, mm);

            file.MoveTo(first.FullName + ".ready");
            return mm;
        }