/// <summary>
        /// Build list of attachments in the mime message.
        /// </summary>
        /// <param name="InPartList"></param>
        /// <returns></returns>
        public MimeAttachmentList BuildList(MimeMessagePartList InPartList)
        {
            // clear the list
            Clear( );

            AcEnumerator it = InPartList.BeginParts( );

            for (it = InPartList.FirstPart( ); it.Current != null; it.MoveNext( ))
            {
                MimeMessagePart part = (MimeMessagePart)it.Current;
                PartProperty.ContentDisposition disp = part.Properties.ContentDisposition;
                if ((disp != null) && (disp.Disposition == "attachment"))
                {
                    AddNewAttachment(part);
                }
            }
            return(this);
        }
Exemple #2
0
        ParseContentDisposition(string InString)
        {
            TextTraits traits = new TextTraits()
                                .SetQuoteEncapsulation(QuoteEncapsulation.Escape);

            traits.DividerPatterns.Replace(
                new string[] { ";", " ", "\t", "=" }, DelimClassification.DividerSymbol);
            traits.WhitespacePatterns.Replace(" ", "\t", DelimClassification.Whitespace);
            PartProperty.ContentDisposition results = new PartProperty.ContentDisposition();

            WordCursor csr = Scanner.PositionBeginWord(InString, traits);

            while (true)
            {
                csr = Scanner.ScanNextWord(InString, csr);
                if (csr.IsEndOfString)
                {
                    break;
                }

                // content disposition
                if (csr.DelimValue == ";")
                {
                    results.Disposition = csr.Word.ToString( ).ToLower( );
                }

                // a kwd
                else if (csr.DelimValue == "=")
                {
                    WordCursor nxCsr = csr.NextWord( );
                    if ((nxCsr.DelimClass == DelimClassification.EndOfString) ||
                        (nxCsr.DelimClass == DelimClassification.Whitespace))
                    {
                        string kwd = csr.Word.ToString( ).ToLower( );
                        csr = nxCsr;
                        if (kwd == "filename")
                        {
                            results.FileName = csr.Word.NonQuotedSimpleValue;
                        }
                    }
                }
            }
            return(results);
        }
        ParseContentDisposition(string InString)
        {
            TextTraits traits = new TextTraits( )
                                .SetDelimChars("; \t=")
                                .SetWhitespaceChars(" \t")
                                .SetQuoteEncapsulation(QuoteEncapsulation.Escape);

            PartProperty.ContentDisposition results = new PartProperty.ContentDisposition( );

            Scanner.WordCursor csr = Scanner.PositionBeginWord( );
            while (true)
            {
                csr = Scanner.ScanNextWord(InString, csr, traits);
                if (csr.IsEndOfString)
                {
                    break;
                }

                // content disposition
                if (csr.Delim == ";")
                {
                    results.Disposition = csr.Word.ToString( ).ToLower( );
                }

                // a kwd
                else if (csr.Delim == "=")
                {
                    Scanner.WordCursor nxCsr = csr.NextWord( );
                    if ((nxCsr.DelimClass == DelimClassification.End) ||
                        (nxCsr.DelimClass == DelimClassification.Whitespace))
                    {
                        string kwd = csr.Word.ToString( ).ToLower( );
                        csr = nxCsr;
                        if (kwd == "filename")
                        {
                            results.FileName = csr.Word.NonQuotedWord;
                        }
                    }
                }
            }
            return(results);
        }