How do I parse and convert DateTime’s to the RFC 822 date-time format?

Try this: DateTime today = DateTime.Now; String rfc822 = today.ToString(“r”); Console.WriteLine(“RFC-822 date: {0}”, rfc822); DateTime parsedRFC822 = DateTime.Parse(rfc822); Console.WriteLine(“Date: {0}”, parsedRFC822); The “r” format specifier passed into DateTime’s ToString() method actually yields an RFC-1123-formatted datetime string, but passes as an RFC-822 date as well, based on reading the specification found at http://www.w3.org/Protocols/rfc822/#z28. I’ve used this … Read more

How can I get an email message’s text content using Python?

In a multipart e-mail, email.message.Message.get_payload() returns a list with one item for each part. The easiest way is to walk the message and get the payload on each part: import email msg = email.message_from_string(raw_message) for part in msg.walk(): # each part is a either non-multipart, or another multipart message # that contains further parts… Message … Read more