public ActionResult Mail() { MimeReader mime = new MimeReader(); var vm = new List <MailViewModel>(); var path = HostingEnvironment.MapPath(@"/App_Data"); foreach (var file in Directory.GetFiles($@"{path}", "*.eml")) { RxMailMessage msg = mime.GetEmail(file); vm.Add(new MailViewModel() { Id = Path.GetFileNameWithoutExtension(file), Sent = msg.DeliveryDate, To = msg.To.Select(s => s.Address.ToString()), CC = msg.CC.Select(s => s.Address.ToString()), From = msg.From.Address, Subject = msg.Subject.Replace("(Trial Version)", ""), Body = msg.Body, Attachments = msg.Attachments.ToList() }); } return(View(vm.OrderByDescending(x => x.Sent))); }
public string GetBody(string path) { MimeReader mime = new MimeReader(); RxMailMessage mm = mime.GetEmail(path); return(GetPlainText(mm)); //divList.Style.Add("display", "none"); //divDetails.Style.Remove("display"); }
public object Get() { MimeReader mime = new MimeReader(); // this class processes the .EML mime content // this get's the MailMessage into Peter's RxMailMessage class // which is derived from the MS MailMessage class string sEmlPath = @"C:\Temp\emails\approve-task.eml"; RxMailMessage mm = mime.GetEmail(sEmlPath); var dto = _context.Users.Include(g => g.Groups).ToList(); return(Ok(dto)); }
private static void readMail() { try { foreach (string file in Directory.EnumerateFiles(ConfigurationManager.AppSettings["sEmlPath"])) { if (file.Contains(".msg")) { ReadMsgFile.ReadOutlookMail(file); } else { MimeReader mime = new MimeReader(); RxMailMessage mm = mime.GetEmail(file); string detils = ReadEmlFile.GetPlainText(mm); } } } catch (Exception) { throw; } }
private void LeerEML(string Carpeta, string Archivo, string PST, Int16 IdPST) { try { MimeReader mime = new MimeReader(); string Remitente = ""; Int64 IdCorreo = 0; //FechaIniPerf = DateTime.Now; //TrackPerformance RxMailMessage msg = mime.GetEmail(Archivo); //RegistrarLogDesempenno("GetEmail"); //TrackPerformance if (msg != null) { List <stAdjuntos> Adjuntos = new List <stAdjuntos> { }; List <stDestinatarios> Destinatarios = new List <stDestinatarios> { }; //FechaIniPerf = DateTime.Now; //TrackPerformance Adjuntos = ObtenerAdjuntos(Carpeta, Archivo, PST); //RegistrarLogDesempenno("ObtenerAdjuntos"); //TrackPerformance //FechaIniPerf = DateTime.Now; //TrackPerformance Destinatarios = ObtenerDestinarios(ref msg, PST, Archivo); //RegistrarLogDesempenno("ObtenerDestinarios"); //TrackPerformance if (msg.From != null) { Remitente = msg.From.Address; } else { if (msg.Sender != null) { Remitente = msg.Sender.Address; } else { Remitente = ""; } } //FechaIniPerf = DateTime.Now; //TrackPerformance IdCorreo = InsertarCorreo(IdPST, Remitente, msg.DeliveryDate, msg.Subject, GetMailText(msg), Archivo, PST, Carpeta.Replace(vRuta, "")); //RegistrarLogDesempenno("InsertarCorreo"); //TrackPerformance if (IdCorreo > 0) { foreach (stAdjuntos att in Adjuntos.Distinct()) { try { //FechaIniPerf = DateTime.Now; //TrackPerformance InsertarAdjuntos(IdCorreo, Carpeta.Replace(vRuta, ""), att.Archivo, att.Extension, att.Tamanno); //RegistrarLogDesempenno("InsertarAdjuntos"); //TrackPerformance } catch (Exception ex) { RegistrarLogLocal("InsertarAdjuntosCall", ex.Message, PST, Archivo); } } List <string> DestinatariosF = new List <string> { }; foreach (stDestinatarios dest in Destinatarios.Distinct()) { try { //FechaIniPerf = DateTime.Now; //TrackPerformance if (!DestinatariosF.Contains(dest.Direccion)) { InsertarDestinatarios(IdCorreo, dest.Direccion, dest.Nombre); DestinatariosF.Add(dest.Direccion); } //RegistrarLogDesempenno("InsertarDestinatarios"); //TrackPerformance } catch (Exception ex) { RegistrarLogLocal("InsertarDestinatariosCall", ex.Message, PST, Archivo); } } } msg.Dispose(); } } catch (Exception ex) { RegistrarLogLocal("LeerEML", ex.Message, PST, Archivo); } }