/// <summary> /// Parses multiple IDs from a single string like In-Reply-To. /// </summary> /// <param name="headerValue">The value to parse</param> /// <returns>A list of IDs</returns> public static List <string> ParseMultipleIDs(string headerValue) { List <string> returner = new List <string>(); string[] ids = headerValue.Trim().Split(new char[] { '>' }, StringSplitOptions.RemoveEmptyEntries); string[] array = ids; for (int i = 0; i < array.Length; i++) { string id = array[i]; returner.Add(HeaderFieldParser.ParseId(id)); } return(returner); }
private void ParseHeader(string headerName, string headerValue) { if (headerName == null) { throw new ArgumentNullException("headerName"); } if (headerValue == null) { throw new ArgumentNullException("headerValue"); } string text = headerName.ToUpperInvariant(); switch (text) { case "TO": this.To = RfcMailAddress.ParseMailAddresses(headerValue); return; case "CC": this.Cc = RfcMailAddress.ParseMailAddresses(headerValue); return; case "BCC": this.Bcc = RfcMailAddress.ParseMailAddresses(headerValue); return; case "FROM": this.From = RfcMailAddress.ParseMailAddress(headerValue); return; case "REPLY-TO": this.ReplyTo = RfcMailAddress.ParseMailAddress(headerValue); return; case "SENDER": this.Sender = RfcMailAddress.ParseMailAddress(headerValue); return; case "KEYWORDS": { string[] keywordsTemp = headerValue.Split(new char[] { ',' }); string[] array = keywordsTemp; for (int i = 0; i < array.Length; i++) { string keyword = array[i]; this.Keywords.Add(Utils.RemoveQuotesIfAny(keyword.Trim())); } return; } case "RECEIVED": this.Received.Add(new Received(headerValue.Trim())); return; case "IMPORTANCE": this.Importance = HeaderFieldParser.ParseImportance(headerValue.Trim()); return; case "DISPOSITION-NOTIFICATION-TO": this.DispositionNotificationTo = RfcMailAddress.ParseMailAddresses(headerValue); return; case "MIME-VERSION": this.MimeVersion = headerValue.Trim(); return; case "SUBJECT": this.Subject = Utils.Decode(headerValue); return; case "RETURN-PATH": this.ReturnPath = RfcMailAddress.ParseMailAddress(headerValue); return; case "MESSAGE-ID": this.MessageId = HeaderFieldParser.ParseId(headerValue); return; case "IN-REPLY-TO": this.InReplyTo = HeaderFieldParser.ParseMultipleIDs(headerValue); return; case "REFERENCES": this.References = HeaderFieldParser.ParseMultipleIDs(headerValue); return; case "DATE": this.Date = headerValue.Trim(); this.DateSent = Utils.StringToDate(headerValue); return; case "CONTENT-TRANSFER-ENCODING": this.ContentTransferEncoding = HeaderFieldParser.ParseContentTransferEncoding(headerValue.Trim()); return; case "CONTENT-DESCRIPTION": this.ContentDescription = Utils.Decode(headerValue.Trim()); return; case "CONTENT-TYPE": this.ContentType = HeaderFieldParser.ParseContentType(headerValue); return; case "CONTENT-DISPOSITION": this.ContentDisposition = HeaderFieldParser.ParseContentDisposition(headerValue); return; case "CONTENT-ID": this.ContentId = HeaderFieldParser.ParseId(headerValue); return; } this.UnknownHeaders.Add(headerName, headerValue); }