Ejemplo n.º 1
0
        private void OpenMail(string mailPath, SaveMailToPdfRequest model)
        {
            InstantiateOutlook();

            string mailExt = Path.GetExtension(mailPath);

            if (mailExt.Equals(".msg", StringComparison.InvariantCultureIgnoreCase))
            {
                _logger.WriteInfo(new LogMessage(string.Concat("OpenMail -> item ", mailPath, " is .msg file. Open item with outlook directly.")), LogCategories);
                _outlookMail = OpenSharedItem(mailPath);
                return;
            }

            _logger.WriteInfo(new LogMessage(string.Concat("OpenMail -> item ", mailPath, " is not .msg file. Try build message manually.")), LogCategories);
            MailBuilder builder = new MailBuilder();
            IMail       mail    = builder.CreateFromEmlFile(mailPath);

            _outlookMail = ConvertToMsg(mail, model);

            if (_outlookMail == null)
            {
                _logger.WriteError(new LogMessage(string.Concat("OpenMail -> item ", mailPath, " not open. Check if item is a correct email message.")), LogCategories);
                throw new Exception("Mail not open. Check if item is a correct email message.");
            }
        }
Ejemplo n.º 2
0
        private void Process()
        {
            var builder = new MailBuilder();
            var enumerator = new WindowsLiveEmlEnumerator(_accountProvider).EnumerateFiles();

            foreach (var emlItem in enumerator)
            {
                _logger.InfoFormat("Parse EML File: {0}", emlItem.EmlFileName);

                try
                {
                    var eMail = builder.CreateFromEmlFile(emlItem.EmlFileName);
                    var processor = _emailProcessor.FirstOrDefault(p => p.LoadMail(eMail, emlItem.Folder));

                    if (processor != null)
                    {
                        try
                        {
                            processor.Publish(_publisher);
                        }
                        catch (Exception ex)
                        {
                            _logger.Error("PARSER_ENGINE_ERROR_SEND_TO_QUEUE", ex);
                        }
                    }

                    try
                    {
                        File.Delete(emlItem.EmlFileName);
                    }
                    catch (Exception ex)
                    {
                        _logger.ErrorFormat("Error deleting Eml File: {1} {0}", ex, emlItem.EmlFileName);
                    }
                }
                catch (Exception e)
                {
                    _logger.ErrorFormat("PARSER ERROR Parsing Eml File: {1} {0}", e, emlItem.EmlFileName);
                    continue;
                }

            }
        }