public bool Validate() { ImapClient imapClient = new ImapClient(Account); Error = string.Empty; int tryCount = 2; if (imapClient.Connect(tryCount)) { imapClient.Disconnect(); } else { Error = imapClient.Error; return false; } SmtpClient smtpClient = new SmtpClient(Account); if (smtpClient.Connect()) { smtpClient.Disconnect(); } else { Error = smtpClient.Error; return false; } return true; }
public void SendEmail() { OutgoingEmail email = new OutgoingEmail(); email.To = ExtractRecipients(toAccounts); if (!String.IsNullOrEmpty(CcAccounts)) email.Cc = ExtractRecipients(CcAccounts); if (!String.IsNullOrEmpty(BccAccounts)) email.Bcc = ExtractRecipients(BccAccounts); email.Subject = Subject; email.Message = MessageBody; if (isHtml) email.HtmlPart = HtmlBody; if (Attachments != null) { List<string> attachmentFilePaths = new List<string>(); foreach (AttachmentViewModel attachmentVm in Attachments) { attachmentFilePaths.Add(attachmentVm.FilePath); } StoreEntities(email, attachmentFilePaths); } SmtpClient NewConnection = new SmtpClient(FromAccount, email); if (!NewConnection.Connect()) { Trace.WriteLine(NewConnection.Error); MessageBoxResult result = MessageBox.Show(NewConnection.Error); return; } if (!NewConnection.SendMail(isHtml)) { Trace.WriteLine(NewConnection.Error); MessageBoxResult result = MessageBox.Show(NewConnection.Error); return; } SaveFavorites(email); FinishInteraction(); Attachments.Clear(); NewConnection.Disconnect(); }