Exemple #1
0
        /// <summary>
        /// Creates the single.
        /// </summary>
        /// <param name="EMail">The E mail.</param>
        /// <returns></returns>
        protected OutputMessage CreateSingle(string ToEMail, NameValueCollection headers)
        {
            Pop3MessageModifier md = new Pop3MessageModifier(EMailMessage.GetPop3MessageBytes(_sourceMsg));

            // Step 1. Change Headers
            md.Headers["From"] = this.From;
            md.Headers["To"]   = ToEMail;

            // Step 2. Remove Headers
            md.Headers.Remove("cc");
            md.Headers.Remove("bcc");
            md.Headers.Remove("Sender");
            md.Headers.Remove("Reply-To");
            md.Headers.Remove("Reply-To");

            // OZ 2009-01-22 Exchange 2007 Problem
            md.Headers.Remove("Thread-Topic");
            md.Headers.Remove("Thread-Index");

            // OZ 2009-02-05 Gmail Problem
            md.Headers.Remove("Message-ID");

            if (this.Subject != null)
            {
                md.Headers["Subject"] = this.Subject;
            }

            // Remove all incoming command
            foreach (string Key in md.Headers.AllKeys)
            {
                string UKey = Key.ToUpper();
                if (UKey.StartsWith("X-IBN-"))
                {
                    md.Headers.Remove(Key);
                }
            }

            foreach (string Key in headers.AllKeys)
            {
                md.Headers.Remove(Key);
                md.Headers.Add(Key, headers[Key]);
            }

            foreach (string Key in this.AdditionalHeaders.AllKeys)
            {
                md.Headers.Remove(Key);
                md.Headers.Add(Key, this.AdditionalHeaders[Key]);
            }

            OutputMessage retVal = new OutputMessage();

            retVal.Data     = md.GetBuffer();
            retVal.MailFrom = this.MailFrom;
            retVal.RcptTo   = ToEMail;
            retVal.Subject  = md.Headers["Subject"];

            return(retVal);
        }