Beispiel #1
0
        /// <summary>
        /// Gets all eml-files from the mailfolder that are marked as unsent.
        /// </summary>
        /// <param name="start">The start.</param>
        /// <param name="mails">The mails.</param>
        private void GetUnblockedAndUnsentEmlFilesInDirectory(DirectoryInfo start, ref List <FileInfo> mails)
        {
            foreach (DirectoryInfo current in start.GetDirectories())
            {
                this.GetUnblockedAndUnsentEmlFilesInDirectory(current, ref mails);
            }

            foreach (FileInfo current in start.GetFiles())
            {
                if (
                    EmlFile.IsUnblocked(current) &&
                    EmlFile.IsUnsentMail(current) &&
                    ForwardingConfiguration.IsConfiguredForForwarding(EmlFile.GetRecepientDomain(current)))
                {
                    mails.Add(current);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Forwards all files in the files parameter to the configured destination.
        /// </summary>
        /// <param name="files">The files.</param>
        private void ForwardMails(List <FileInfo> files)
        {
            foreach (FileInfo current in files)
            {
                try
                {
                    String ip   = ForwardingConfiguration.IpOfDomain(EmlFile.GetRecepientDomain(current));
                    String host = ForwardingConfiguration.HostnameOfDomain(EmlFile.GetRecepientDomain(current));

                    if (EmlFile.Forward(current, ip, host))
                    {
                        EmlFile.MarkAsSent(current);
                    }
                }
                catch (Exception ex)
                {
                    Tracing.Exception(ex);
                }
            }
        }