Esempio n. 1
0
 private void ParseMessage(System.IO.Stream stream, MimeTopLevelMediaType types, DecodeOptions options, System.String preferredtextsubtype, System.String path)
 {
     this._attachments = new System.Collections.ArrayList();
     MimeMessage message = new MimeMessage(stream);
     this.ParseMessage(message, types, (options & DecodeOptions.AllowHtml) == DecodeOptions.AllowHtml, options, preferredtextsubtype, path);
     this._headers = message.Header;
     message.Close();
     // find and decode uuencoded content if configured to do so (and attachments a allowed)
     if ((options & DecodeOptions.UuDecode) == DecodeOptions.UuDecode
            && (options & DecodeOptions.AllowAttachments) == DecodeOptions.AllowAttachments)
         this.UuDecode(path);
     // Date
     this._date = MimeTools.parseDate(this._headers.Date);
     if (this._date.Equals(System.DateTime.MinValue))
     {
         System.String date = this._headers["Received"] ?? System.String.Empty;
         if (date.IndexOf("\r\n", System.StringComparison.Ordinal) > 0)
             date = date.Substring(0, date.IndexOf("\r\n", System.StringComparison.Ordinal));
         date = date.LastIndexOf(';') > 0 ? date.Substring(date.LastIndexOf(';') + 1).Trim() : System.String.Empty;
         this._date = MimeTools.parseDate(date);
     }
     // Subject
     this._subject = MimeTools.parserfc2047Header(this._headers.Subject);
     // To
     this._to = MimeAddressCollection.Parse(this._headers.To);
     // From
     MimeAddressCollection from = MimeAddressCollection.Parse(this._headers.From);
     foreach (MimeAddress item in from)
     {
         this._from_name = item["name"];
         this._from_addr = item["address"];
         if (this._from_name == null || this._from_name.Equals(System.String.Empty))
             this._from_name = item["address"];
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Parse a rfc 2822 address specification. rfc 2822 section 3.4
 /// </summary>
 /// <param name="from">field body to parse</param>
 /// <returns>A <see cref="System.Collections.IEnumerable" /> collection of <see cref="MimeAddress" /></returns>
 public static System.Collections.IEnumerable parseFrom(System.String from)
 {
     return(MimeAddressCollection.Parse(from));
 }