public void MockSave() { var item = new EmailModel { Data = DateTime.Now}; dbStore.EmailModel.Add(item); dbStore.SaveChanges(); }
/// <summary> /// Save Email /// </summary> /// <param name="email"></param> private void SaveEmail(OpenPop.Mime.Message email) { System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); string strBody = ""; if (email.MessagePart.Body != null) { strBody = enc.GetString(email.MessagePart.Body); } else if (email.MessagePart.MessageParts[0].Body != null) { strBody = enc.GetString(email.MessagePart.MessageParts[0].Body); } else if (email.MessagePart.MessageParts[1].Body != null) { strBody = enc.GetString(email.MessagePart.MessageParts[1].Body); } var item = new EmailModel { Data = email.Headers.DateSent, Sender = email.Headers.From.MailAddress.ToString(), Title = email.Headers.Subject, MessageBody = strBody, Subject = email.Headers.Subject }; dbStore.EmailModel.Add(item); dbStore.SaveChanges(); }