Esempio n. 1
0
        private String GetDestino(Mail oMail, String Tipe)
        {
            try
            {
                //Rutas Para Guardar los Archivos de respaldo y Grabacion del mensaje
                string Destino = @"\\10.177.1.220\MAILACF\";  /// RPETC_ACF"; //+ SToday;
                //string PathHistoric = SavePath;
                System.Globalization.CultureInfo cur = new
                                                       System.Globalization.CultureInfo("en-US");
                string sdate = Today.ToString("yyyyMMddHHmmss", cur);
                string Sday  = Today.ToString("yyyyMMdd", cur);

                FilterMail fl    = new FilterMail();
                String     Ofrom = (oMail.From.ToString());
                //ReceiveMail rv = new ReceiveMail();
                fl.ShopEmail(ref Ofrom);


                switch (Tipe)
                {
                case "1":        //////-  --1 = RPTC
                    Destino = Destino + @"RPETC";
                    MailProcessed++;
                    break;

                case "2":       //////-- - 2 = XML
                    Destino = Destino + @"XML\" + Ofrom;
                    MailProcessed++;
                    break;

                case "3":      //////-- - 3 = DICOM
                    Destino = Destino + @"DICOM";
                    MailProcessed++;
                    break;

                case "4":      //////-- - 4 = RESPALDOS
                    Destino = Destino + @"RESPALDOS\" + Ofrom;
                    MailProcessed++;
                    break;

                default:      //// descartados
                    Destino = Destino + @"DESCARTADOS";
                    MailPurging++;
                    break;
                }

                Destino = String.Format("{0}\\{1}", Destino, Sday);

                /////crea la ruta del dia en que se recibio
                //string PathHist = String.Format(PathHistoric + Sday,
                //PathHistoric, sdate, Today.Millisecond.ToString("d3"), i);

                ///crea la ruta del mensaje de respaaldo a guardar

                //string HistFile = String.Format("{0}" + Sday + "\\{1}{2}{3}.msg",
                //           PathHistoric, sdate, Today.Millisecond.ToString("d3"), i);

                //determina si el directorio existe , sino lo crea.
                FileManager Rcsv = new FileManager();
                Rcsv.ScanFilePath(Destino);
                //sv.ScanFilePath(PathHist);

                return(Destino);
            } catch (Exception ep)
            {
                Logs.Log("ReceiveMail.GetDestino", ep.Message.ToString());
                return("");
            }

            //return "";
        }
Esempio n. 2
0
        public Boolean SaveMail(Mail oMail, int i, ref String SavePath)
        {
            ////rea un directorio y carpeta llamada mailbox
            ////para guardar los correos en ella
            string curpath  = Directory.GetCurrentDirectory();
            string mailbox  = String.Format("{0}\\inbox", curpath);
            string FilePath = "";

            //teTime Today = DateTime.Now;


            //FilterMail ObjFil = new FilterMail();

            // si la carpeta no existe la crea(Mailbox)
            if (!Directory.Exists(mailbox))
            {
                Directory.CreateDirectory(mailbox);
            }
            try
            {
                FileManager Rcsv = new FileManager();
                //Rutas Para Guardar los Archivos de respaldo y Grabacion del mensaje
                //string PathHistoric = @"\\10.177.1.230\MAILACF$\RPETC_ACF"; //+ SToday;
                string PathHistoric = SavePath;
                System.Globalization.CultureInfo cur = new
                                                       System.Globalization.CultureInfo("en-US");
                string sdate = Today.ToString("yyyyMMddHHmmss", cur);
                string Sday  = Today.ToString("yyyyMMdd", cur);

                //System.Globalization.CultureInfo cur = new
                //System.Globalization.CultureInfo("en-US");
                //string sdate = Today.ToString("yyyyMMddHHmmss", cur);
                string fileName = String.Format("{0}\\{1}{2}{3}.msg",
                                                mailbox, sdate, Today.Millisecond.ToString("d3"), i);
                FilePath = fileName;


                ///crea la ruta del dia en que se recibio
                string PathHist = String.Format(PathHistoric + Sday,
                                                PathHistoric, sdate, Today.Millisecond.ToString("d3"), i);

                ///crea la ruta del mensaje de respaaldo a guardar

                string HistFile = String.Format("{0}" + Sday + "\\{1}{2}{3}.msg",
                                                PathHistoric, sdate, Today.Millisecond.ToString("d3"), i);

                //determina si el directorio existe , sino lo crea.
                Rcsv.ScanFilePath(PathHistoric);
                Rcsv.ScanFilePath(PathHist);

                if (fileName != null)
                {
                    //oMail.SaveAs(fileName, true);guardar como eml
                    oMail.SaveAsOMSG(fileName, true, true);
                }
                if (HistFile != null)
                {
                    //oMail.SaveAs(HistFile, true, true);guardar como eml
                    oMail.SaveAsOMSG(HistFile, true, true);
                    SavePath = HistFile;
                }
                if (fileName != null && PathHistoric != null)
                {
                    //GUARDO EXITOSAMENTE

                    //Logs.Log("ReceiveMail.SaveMail", "Guardo Exitosamente el MSG");
                    /////-------- delarar salida de servidor: Marcado de correos descargados y cerraar conexion
                    //  PoClient

                    return(true);
                }
                else
                {
                    Logs.Log("ReceiveMail.SaveMail", "ERROR- No se logró Guardar el MSG");
                    return(false);
                }
            }
            catch (Exception ep)
            {
                Logs.Log("ReceiveMail.SaveMail", ep.Message.ToString());
                return(false);
                //throw;
            }

            //return true;
        }
Esempio n. 3
0
        private Boolean ParseMailsFromInbox()
        {
            try
            {
                Logs.Log("ReceiveMail.ParseMailsFromInbox", "Tratando de Parsear Correos - Iniciando....");

                //List<string> Files = new List<string>();
                Mail oMail = new Mail("TryIt");
                //String MailPath = @""+Itm;
                /*oMail.LoadOMSG(Itm);  */  ////carga el msg como un objeto
                //oMail.Load(Itm, true);

                System.Globalization.CultureInfo cur = new
                                                       System.Globalization.CultureInfo("en-US");
                //string sdate = Today.ToString("yyyyMMddHHmmss", cur);
                string Sday = Today.ToString("yyyyMMdd", cur);

                string curpath = Directory.GetCurrentDirectory();
                string Mailbox = String.Format("{0}\\MailBox\\{1}", curpath, Sday);

                FileManager Rcsv = new FileManager();
                Rcsv.ScanFilePath(Mailbox);

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

                //foreach (string file in Directory.EnumerateFiles(Mailbox, "*.eml"))
                //{
                //    String Paths = Path.GetFullPath(file);
                //    Files.Add(Paths);
                //    //oMail.Load(file, true);
                //}

                FilterMail fl    = new FilterMail();
                int        Count = files.Length;
                MailCounting = files.Length;
                Logs.Log("Se contaron: " + MailCounting, " Correos disponibles en Inbox");
                for (int i = 0; i < Count; i++)
                {
                    String FileRoute = files[i];
                    String fname     = Path.GetFileName(FileRoute);
                    oMail.Load(files[i], true);
                    fl.Filter(oMail, i, fname);

                    String Tipe = (fl.IsType);

                    String Origen  = files[i];
                    String Destino = GetDestino(oMail, Tipe);

                    MoveMail(Origen, Destino);
                    //if(Tipe==1 || Tipe == 2)
                    //    MailProcessed++;

                    //if (Tipe == 3 || Tipe == 4)
                    //{
                    //    MailProcessed++;
                    //}
                    //else
                    //{
                    //    MailPurging++;
                    //}
                }

                Logs.Log("Procesados: " + MailProcessed, "de: " + MailCounting + "Descartados: " + MailPurging);


                //foreach (string itm in Files)
                //{

                //    oMail.Load(itm, true);
                //    fl.Filter(oMail,itm);


                //}

                //PendingLoadMail(Files);

                //int Count = files.Length;
                //for (int i = 0; i < Count; i++)
                //{
                //    //ParseEmail(files[i]);
                //    FilterMail fl = new FilterMail();
                //    fl.ProcessMail(files);
                //    fl.PendingProcess();
                //    //ObjFil.Filter(oMail, i);
                //}

                //Logs.Log("ReceiveMail.ParseMailsFromInbox", "Correos Parseados Correctamente. Cantidad: " + Count);
                return(true);
            }
            catch (Exception e)
            {
                Logs.Log("ReceiveMail.ParseMailsFromInbox", "Error en Parsing Mails Desde Inbox: " + e.Message.ToString());
                return(false);
            }
        }