コード例 #1
0
ファイル: Header.cs プロジェクト: slavat/MailSystem.NET
        /// <summary>
        /// Detects if a message is a delivery failure notification.
        /// This method uses the default signatures containing in an internal ressource file.
        /// </summary>
        /// <remarks>
        /// Signature files are XML files formatted as follows :
        ///
        /// &lt;?xml version='1.0'?&gt;
        /// &lt;signatures&gt;
        ///		&lt;signature from=&quot;postmaster&quot; subject=&quot;Undeliverable Mail&quot; body=&quot;Unknown user&quot; search=&quot;&quot; />
        ///		...
        /// &lt;/signatures&gt;
        /// </remarks>
        /// <returns>A BounceStatus object containing the level of revelance and if 100% identified, the erroneous email address.</returns>
        public BounceResult GetBounceStatus(string signaturesFilePath)
        {
            string ressource = string.Empty;

            if (signaturesFilePath == null || signaturesFilePath == string.Empty)
            {
                ressource = Header.GetResource("ActiveUp.Net.Mail.bouncedSignatures.xml");
            }
            else
            {
                ressource = System.IO.File.OpenText(signaturesFilePath).ReadToEnd();
            }
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.LoadXml(ressource);
            BounceResult result = new BounceResult();

            foreach (System.Xml.XmlElement el in doc.GetElementsByTagName("signature"))
            {
                if (this.From.Merged.IndexOf(el.GetElementsByTagName("from")[0].InnerText) != -1)
                {
                    result.Level++;
                }

                if (this.Subject != null && this.Subject.IndexOf(el.GetElementsByTagName("subject")[0].InnerText) != -1)
                {
                    result.Level++;
                }
            }

            return(result);
        }
コード例 #2
0
        /// <summary>
        /// Detects if a message is a delivery failure notification.
        /// This method uses the default signatures containing in an internal ressource file.
        /// </summary>
        /// <remarks>
        /// Signature files are XML files formatted as follows :
        ///
        /// &lt;?xml version='1.0'?&gt;
        /// &lt;signatures&gt;
        ///        &lt;signature from=&quot;postmaster&quot; subject=&quot;Undeliverable Mail&quot; body=&quot;Unknown user&quot; search=&quot;&quot; />
        ///        ...
        /// &lt;/signatures&gt;
        /// </remarks>
        /// <returns>A BounceStatus object containing the level of revelance and if 100% identified, the erroneous email address.</returns>
        public BounceResult GetBounceStatus(string signaturesFilePath)
        {
            string ressource = string.IsNullOrEmpty(signaturesFilePath) ? GetResource("ActiveUp.Net.Common.bouncedSignatures.xml") : File.OpenText(signaturesFilePath).ReadToEnd();
            var    doc       = new System.Xml.XmlDocument();

            doc.LoadXml(ressource);
            var result = new BounceResult();

            foreach (System.Xml.XmlElement el in doc.GetElementsByTagName("signature"))
            {
                if (From.Merged.IndexOf(el.GetElementsByTagName("from")[0].InnerText) != -1)
                {
                    result.Level++;
                }

                if (Subject != null && Subject.IndexOf(el.GetElementsByTagName("subject")[0].InnerText) != -1)
                {
                    result.Level++;
                }
            }

            return(result);
        }
コード例 #3
0
ファイル: Message.cs プロジェクト: JBTech/MailSystem.NET
        /// <summary>
        /// Detects if a message is a delivery failure notification.
        /// This method uses the default signatures containing in an internal ressource file.
        /// </summary>
        /// <remarks>
        /// Signature files are XML files formatted as follows : 
        /// 
        /// &lt;?xml version='1.0'?&gt;
        /// &lt;signatures&gt;
        ///		&lt;signature from=&quot;postmaster&quot; subject=&quot;Undeliverable Mail&quot; body=&quot;Unknown user&quot; search=&quot;&quot; />
        ///		...
        /// &lt;/signatures&gt;
        /// </remarks>
        /// <returns>A BounceStatus object containing the level of revelance and if 100% identified, the erroneous email address.</returns>
        public new BounceResult GetBounceStatus(string signaturesFilePath)
        {
            string ressource = string.Empty;
            
            if (signaturesFilePath == null || signaturesFilePath == string.Empty)
                ressource = Header.GetResource("ActiveUp.Net.Mail.bouncedSignatures.xml");
            else
                ressource = System.IO.File.OpenText(signaturesFilePath).ReadToEnd();

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.LoadXml(ressource);
            BounceResult result = new BounceResult();

            foreach (System.Xml.XmlElement el in doc.GetElementsByTagName("signature"))
            {
                int bestResult = result.Level;
                result.Level = 0;

                if (el.GetAttribute("from").Trim() != "")
                    if (this.From.Merged.IndexOf(el.GetAttribute("from")) != -1)
                        result.Level++;

                if (this.Subject != null && el.GetAttribute("subject").Trim() != "")
                    if (this.Subject.IndexOf(el.GetAttribute("subject")) != -1)
                        result.Level++;

                if (el.GetAttribute("body").Trim() != "")
                    if (this.BodyText.Text.IndexOf(el.GetAttribute("body")) != -1)
                        result.Level++;

                if (result.Level < bestResult)
                    result.Level = bestResult;

                if (result.Level > 0)
                {
                    int start = 0;
                    string body = this.BodyText.Text;

                    if (el.GetAttribute("body") != string.Empty)
                        start = body.IndexOf(el.GetAttribute("body"));

                    if (start < 0)
                        start = 0;

                    string emailExpression = "\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*";
                    System.Text.RegularExpressions.Regex regExp = new System.Text.RegularExpressions.Regex(emailExpression);

                    if (regExp.IsMatch(body, start))
                    {
                        System.Text.RegularExpressions.Match match = regExp.Match(body, start);
                        result.Email = match.Value;
                    }

                    break;
                }
            }

            return result;
        }
コード例 #4
0
ファイル: Header.cs プロジェクト: haoasqui/MailSystem.NET
        /// <summary>
        /// Detects if a message is a delivery failure notification.
        /// This method uses the default signatures containing in an internal ressource file.
        /// </summary>
        /// <remarks>
        /// Signature files are XML files formatted as follows : 
        /// 
        /// &lt;?xml version='1.0'?&gt;
        /// &lt;signatures&gt;
        ///		&lt;signature from=&quot;postmaster&quot; subject=&quot;Undeliverable Mail&quot; body=&quot;Unknown user&quot; search=&quot;&quot; />
        ///		...
        /// &lt;/signatures&gt;
        /// </remarks>
        /// <returns>A BounceStatus object containing the level of revelance and if 100% identified, the erroneous email address.</returns>
        public BounceResult GetBounceStatus(string signaturesFilePath)
        {
            string ressource = string.Empty;
            
            if (signaturesFilePath == null || signaturesFilePath == string.Empty)
            {
                ressource = Header.GetResource("ActiveUp.Net.Mail.bouncedSignatures.xml");
            }
            else
                ressource = System.IO.File.OpenText(signaturesFilePath).ReadToEnd();
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.LoadXml(ressource);
            BounceResult result = new BounceResult();

            foreach (System.Xml.XmlElement el in doc.GetElementsByTagName("signature"))
            {
                if (this.From.Merged.IndexOf(el.GetElementsByTagName("from")[0].InnerText) != -1)
                    result.Level++;

                if (this.Subject != null && this.Subject.IndexOf(el.GetElementsByTagName("subject")[0].InnerText) != -1)
                    result.Level++;
            }

            return result;
        }