public void Run(EmailCorrespondenceSaverVariables saverVariables)
        {
            mLog.Info("Run started. Looking in '{0}' for attachements.", saverVariables.MailCorrespondenceFilePath);
            mSaverVariables = saverVariables;

            foreach (var filePath in  Directory.GetFiles(saverVariables.MailCorrespondenceFilePath))
            {
                var fileInfo = new FileInfo(filePath);

                if (string.IsNullOrEmpty(fileInfo.Name)) { return; }
                if (!File.Exists(fileInfo.FullName)) { return; }

                mLog.Info("");
                mLog.Info("Found file '{0}'", fileInfo.FullName);

                ProcessMatchedMessage(fileInfo);
            }
        }
Example #2
0
        private static void Main(string[] args)
        {
            try
            {
                mLog.Info("-------------------------------------------------------------------------------------------------");
                mLog.Info("CmsEmailCorrespondenceSaver Started");
                //EMAIL CORRESPONDENT SAVER
                mEmailCorrespondenceSaverEnabled = CommonUtils.GetAppSettingValue(CommonUtils.AppSettingKey.EmailCorrespondenceSaverEnabled, false);
                if (mEmailCorrespondenceSaverEnabled)
                {
                    if (SetUpEmailCorrespondenceSaverSuccesfull())
                    {

                        EmailCorrespondenceSaverVariables vars = new EmailCorrespondenceSaverVariables
                        {
                            EmailCorrespondenceSaverEnabled = mEmailCorrespondenceSaverEnabled,
                            AttachmentTypeId = mAttachmentTypeCorrespondenceId,
                            MailCorrespondenceFilePath = mMailCorrespondenceFilePath,
                            UploadAttachmentPath = mUploadAttachmentPath,
                            UserId = mCmsAdminUserId
                        };
                        CmsEmailCorrespondenceSaver emailCorrespondenceSaver = new CmsEmailCorrespondenceSaver();

                        emailCorrespondenceSaver.Run(vars);
                    }
                }
                else
                {
                    mLog.Warning("", "EmailCorrespondenceSaverEnabled is set to FALSE.  Will not save email correspondence.");
                }
            }
            catch (Exception ex)
            {

                mLog.Error("", ex, "Error occured, please check exception.");
            }
            finally
            {
                mLog.Info("CmsEmailCorrespondenceSaver Finished");
            }
        }