// retrieves mail private async void RetrieveMail() { Folders.Clear(); Emails.Clear(); folderTypes.Clear(); // connect to google using (var client = new ImapClient()) { await client.ConnectAsync("imap.gmail.com", 993, true); client.AuthenticationMechanisms.Remove("XOAUTH2"); client.Authenticate("ece433tester", "thisclassman"); var inbox = client.Inbox; inbox.Open(FolderAccess.ReadOnly); Folders.Add(client.Inbox); if ((client.Capabilities & (ImapCapabilities.SpecialUse | ImapCapabilities.XList)) != 0) { foreach (SpecialFolder folder in Enum.GetValues(typeof(SpecialFolder))) { var fold = client.GetFolder(folder); if (fold != null) { fold.Open(FolderAccess.ReadOnly); folderTypes.Add(folder); Folders.Add(client.GetFolder(folder)); } } } ShowFolder(); client.Disconnect(true); } }
void FindByName(string txt) { Emails.Clear(); GetEmails(); var findedList = Emails.Where(em => em.Name.Contains(txt)); Emails = new ObservableCollection <Email>(findedList); }
private void GetEmails() { Emails.Clear(); foreach (var item in _serviceProxy.GetEmails()) { Emails.Add(item); } }
private async void ShowFolder() { var folder = Folders[SelectedFolderIndex]; if (folder == null) { return; } Emails.Clear(); using (var client = new ImapClient()) { await client.ConnectAsync("imap.gmail.com", 993, true); client.AuthenticationMechanisms.Remove("XOAUTH2"); client.Authenticate("ece433tester", "thisclassman"); IMailFolder fold; if (folder.Name == "INBOX") { fold = client.Inbox; await fold.OpenAsync(FolderAccess.ReadOnly); for (int i = 0; i < fold.Count; i++) { try { var email = fold.GetMessage(i); Emails.Add(email); } catch (Exception) { throw; } } } else { if ((client.Capabilities & (ImapCapabilities.SpecialUse | ImapCapabilities.XList)) != 0) { fold = client.GetFolder(folderTypes[SelectedFolderIndex - 1]); await fold.OpenAsync(FolderAccess.ReadOnly); for (int i = 0; i < fold.Count; i++) { try { var email = fold.GetMessage(i); Emails.Add(email); } catch (Exception) { throw; } } } } client.Disconnect(true); } }
private void GetEmails() { Emails.Clear(); foreach (var item in _serviceProxy.GetEmails()) { Emails.Add(item); } Console.WriteLine(55); }
private void FetchAllMail() { Emails.Clear(); stopToken = new CancellationTokenSource(); Task mailFetcherTask = Task.Run(() => FetchAllInboxEmail(), stopToken.Token); mailFetcherTask.ContinueWith(async(RealTimeMailChecking) => await FetchRealTimeEmail(), stopToken.Token); }
public async void GetAllEmails() { var emails = await _emailSupplier.GetAllAsync(); Emails.Clear(); foreach (Email email in emails) { Emails.Add(new EmailObservable(email)); } }
public virtual int FillByWhereClause(Emails.CustomerEmailsDataTable dataTable, string whereClause, System.Data.OleDb.OleDbParameter[] parameters) { System.Data.OleDb.OleDbCommand command = new System.Data.OleDb.OleDbCommand(); command.Connection = this.Connection; this._commandCollection[0].CommandText = @"SELECT ID, Email, CustomerID, CreateID, CreateUser, ModifyID, ModifyUser FROM CustomerEmails " + whereClause + ";"; command.CommandType = System.Data.CommandType.Text; if (null != parameters) command.Parameters.AddRange(parameters); this.Adapter.SelectCommand = command; if ((this.ClearBeforeFill == true)) { dataTable.Clear(); } int returnValue = this.Adapter.Fill(dataTable); return returnValue; }
private void GetEmails() { Emails.Clear(); if (this.name != null && this.name != "") { foreach (var item in this.serviceProxy.GetEmails()) { if (item.Name == this.name) { Emails.Add(item); } } } else { foreach (var item in this.serviceProxy.GetEmails()) { Emails.Add(item); } } }
/// <summary> /// Метод поиска почты в базе данных по тегу Name /// </summary> private void GetName() { Emails.Clear(); if (Name == null || Name == "") { foreach (var item in _serviceProxy.GetEmails()) { Emails.Add(item); } } else { foreach (var item in _serviceProxy.GetEmails()) { if (Name.ToLower() == item.Name.ToLower() || Name.ToLower() == item.Name.Substring(0, Name.Length).ToLower()) { Emails.Add(item); } } } }
public void FillFromEntity(ContactEntity entity) { FirstName = entity.Name.FirstName; LastName = entity.Name.LastName; Emails.Clear(); Phones.Clear(); foreach (var email in entity.EmailAddresses) { Emails.Add(new ContactEmailModel() { Email = email.Value }); } foreach (var phone in entity.PhoneNumbers) { Phones.Add(new ContactPhoneModel() { PhoneType = phone.PhoneType, PhoneNumber = phone.PhoneNumber }); } }
void GetEmails() { Emails.Clear(); foreach (var item in _serviceProxy.GetEmails()) { Emails.Add(item); } //if (!String.IsNullOrEmpty(PrintedName)) //{ // var newCollection = _serviceProxy.GetEmails().Where(em => em.Name.Contains(PrintedName)); // foreach (var item in newCollection) // { // Emails.Add(item); // } //} //else //{ // foreach (var item in _serviceProxy.GetEmails()) // { // Emails.Add(item); // } //} }
public User ClearUserMailList() { Emails.Clear(); return(this); }
public virtual int Fill(Emails.CustomerEmailsDataTable dataTable) { this.Adapter.SelectCommand = this.CommandCollection[0]; if ((this.ClearBeforeFill == true)) { dataTable.Clear(); } int returnValue = this.Adapter.Fill(dataTable); return returnValue; }
public virtual int FillBy(Emails.CustomerEmailsDataTable dataTable, int ID) { this.Adapter.SelectCommand = this.CommandCollection[1]; this.Adapter.SelectCommand.Parameters[0].Value = ((int)(ID)); if ((this.ClearBeforeFill == true)) { dataTable.Clear(); } int returnValue = this.Adapter.Fill(dataTable); return returnValue; }
public virtual int FillByCustomerId(Emails.CustomerEmailsDataTable dataTable, string CustomerID) { this.Adapter.SelectCommand = this.CommandCollection[2]; if ((CustomerID == null)) { this.Adapter.SelectCommand.Parameters[0].Value = global::System.DBNull.Value; } else { this.Adapter.SelectCommand.Parameters[0].Value = ((string)(CustomerID)); } if ((this.ClearBeforeFill == true)) { dataTable.Clear(); } int returnValue = this.Adapter.Fill(dataTable); return returnValue; }
public virtual int Fill(Emails.CustomerEmailsChangeLogsDataTable dataTable, int ID, global::System.Nullable<int> MAX_SequenceNumber_, global::System.Nullable<int> MAX_SequenceNumber_1, string ChangeUser) { this.Adapter.SelectCommand = this.CommandCollection[0]; this.Adapter.SelectCommand.Parameters[0].Value = ((int)(ID)); if ((MAX_SequenceNumber_.HasValue == true)) { this.Adapter.SelectCommand.Parameters[1].Value = ((int)(MAX_SequenceNumber_.Value)); } else { this.Adapter.SelectCommand.Parameters[1].Value = global::System.DBNull.Value; } if ((MAX_SequenceNumber_1.HasValue == true)) { this.Adapter.SelectCommand.Parameters[2].Value = ((int)(MAX_SequenceNumber_1.Value)); } else { this.Adapter.SelectCommand.Parameters[2].Value = global::System.DBNull.Value; } if ((ChangeUser == null)) { this.Adapter.SelectCommand.Parameters[3].Value = global::System.DBNull.Value; } else { this.Adapter.SelectCommand.Parameters[3].Value = ((string)(ChangeUser)); } if ((this.ClearBeforeFill == true)) { dataTable.Clear(); } int returnValue = this.Adapter.Fill(dataTable); return returnValue; }
//private void DepartSent_SMS() //{ // DataTable dtDepartmentSMSSent = new DataTable(); // dtDepartmentSMSSent = DataAccessManager.GetSMSSent( Convert.ToString(Session["DeptID"]), Convert.ToInt32(Session["CampusID"])); // Session["dtDepartmentSMSSent"] = dtDepartmentSMSSent; // rgvDepartmentSent.DataSource = (DataTable)Session["dtDepartmentSMSSent"]; //} //protected void rgvDepartmentSent_SortCommand(object sender, GridSortCommandEventArgs e) //{ // this.rgvDepartmentSent.MasterTableView.AllowNaturalSort = true; // this.rgvDepartmentSent.MasterTableView.Rebind(); //} //protected void rgvDepartmentSent_PageIndexChanged(object sender, GridPageChangedEventArgs e) //{ // try // { // rgvDepartmentSent.DataSource = (DataTable)Session["dtDepartmentSMSSent"]; // } // catch (Exception ex) // { // } //} #endregion public void fetchmail(string DeptID, int CampusID) { try { DataTable dtEmailConfig = DataAccessManager.GetEmailConfigDetail(DeptID, CampusID); if (dtEmailConfig.Rows.Count > 0) { Pop3Client pop3Client; pop3Client = new Pop3Client(); pop3Client.Connect(dtEmailConfig.Rows[0]["Pop3"].ToString(), Convert.ToInt32(dtEmailConfig.Rows[0]["PortIn"]), Convert.ToBoolean(dtEmailConfig.Rows[0]["SSL"])); pop3Client.Authenticate(dtEmailConfig.Rows[0]["DeptEmail"].ToString(), dtEmailConfig.Rows[0]["Pass"].ToString(), AuthenticationMethod.UsernameAndPassword); if (pop3Client.Connected) { int count = pop3Client.GetMessageCount(); int progressstepno; if (count == 0) { } else { progressstepno = 100 - count; this.Emails = new List <Email>(); for (int i = 1; i <= count; i++) { OpenPop.Mime.Message message = pop3Client.GetMessage(i); Email email = new Email() { MessageNumber = i, messageId = message.Headers.MessageId, Subject = message.Headers.Subject, DateSent = message.Headers.DateSent, From = message.Headers.From.Address }; MessagePart body = message.FindFirstHtmlVersion(); if (body != null) { email.Body = body.GetBodyAsText(); } else { body = message.FindFirstHtmlVersion(); if (body != null) { email.Body = body.GetBodyAsText(); } } email.IsAttached = false; this.Emails.Add(email); //Attachment Process List <MessagePart> attachments = message.FindAllAttachments(); foreach (MessagePart attachment in attachments) { email.IsAttached = true; string FolderName = string.Empty; FolderName = Convert.ToString(Session["CampusName"]); String path = Server.MapPath("~/InboxAttachment/" + FolderName); if (!Directory.Exists(path)) { // Try to create the directory. DirectoryInfo di = Directory.CreateDirectory(path); } string ext = attachment.FileName.Split('.')[1]; // FileInfo file = new FileInfo(Server.MapPath("InboxAttachment\\") + attachment.FileName.ToString()); FileInfo file = new FileInfo(Server.MapPath("InboxAttachment\\" + FolderName + "\\") + attachment.FileName.ToString()); attachment.SaveToFile(file); Attachment att = new Attachment(); att.messageId = message.Headers.MessageId; att.FileName = attachment.FileName; attItem.Add(att); } //System.Threading.Thread.Sleep(500); } //Insert into database Inbox table DataTable dtStudentNo = new DataTable(); bool IsReadAndSave = false; foreach (var ReadItem in Emails) { string from = string.Empty, subj = string.Empty, messId = string.Empty, Ebody = string.Empty; from = Convert.ToString(ReadItem.From); subj = Convert.ToString(ReadItem.Subject); messId = Convert.ToString(ReadItem.messageId); Ebody = Convert.ToString(ReadItem.Body); if (Ebody != string.Empty && Ebody != null) { Ebody = Ebody.Replace("'", " "); } DateTime date = ReadItem.DateSent; bool IsAtta = ReadItem.IsAttached; //Student Email if (Source.SOrL(Convert.ToString(Session["StudentNo"]), Convert.ToString(Session["leadID"]))) { dtStudentNo = DyDataAccessManager.GetStudentNo(from, from); if (dtStudentNo.Rows.Count == 0) { IsReadAndSave = DataAccessManager.ReadEmailAndSaveDatabase("0", Convert.ToString(Session["DeptID"]), messId, dtEmailConfig.Rows[0]["DeptEmail"].ToString(), from, subj, Ebody, IsAtta, date, Convert.ToInt32(Session["CampusID"])); } else { IsReadAndSave = DataAccessManager.ReadEmailAndSaveDatabase(dtStudentNo.Rows[0]["StudentNo"].ToString(), Convert.ToString(Session["DeptID"]), messId, dtEmailConfig.Rows[0]["DeptEmail"].ToString(), from, subj, Ebody, IsAtta, date, Convert.ToInt32(Session["CampusID"])); } } //Leads Email if (Source.SOrL(Convert.ToString(Session["ParamStudentNo"]), Convert.ToString(Session["ParamleadID"])) == false) { dtStudentNo = DyDataAccessManager.GetLeadsID(from, from); if (dtStudentNo.Rows.Count == 0) { IsReadAndSave = DataAccessManager.ReadEmailAndSaveDatabaseLead("0", Convert.ToString(Session["DeptID"]), messId, dtEmailConfig.Rows[0]["DeptEmail"].ToString(), from, subj, Ebody, IsAtta, date, Convert.ToInt32(Session["CampusID"])); } else { IsReadAndSave = DataAccessManager.ReadEmailAndSaveDatabaseLead(dtStudentNo.Rows[0]["LeadsID"].ToString(), Convert.ToString(Session["DeptID"]), messId, dtEmailConfig.Rows[0]["DeptEmail"].ToString(), from, subj, Ebody, IsAtta, date, Convert.ToInt32(Session["CampusID"])); } } // } //Insert into database Attachment table foreach (var attachItem in attItem) { bool success; string Filname = attachItem.FileName; string MssID = attachItem.messageId; success = DataAccessManager.ReadEmailAttachmentAndSaveDatabase(MssID, Filname); } Emails.Clear(); // attItem.Clear(); pop3Client.DeleteAllMessages(); //StartNotification(count); } } pop3Client.Disconnect(); } } catch (Exception ex) { } }