rfc822

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

梦想与她 提交于 2019-11-27 03:49:56
How do I convert a DateTime structure to its equivalent RFC 822 date-time formatted string representation and parse this string representation back to a DateTime structure in .NET? The RFC-822 date-time format is used in a number of specifications such as the RSS Syndication 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

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

允我心安 提交于 2019-11-26 12:06:45
问题 Given an RFC822 message in Python 2.6, how can I get the right text/plain content part? Basically, the algorithm I want is this: message = email.message_from_string(raw_message) if has_mime_part(message, \"text/plain\"): mime_part = get_mime_part(message, \"text/plain\") text_content = decode_mime_part(mime_part) elif has_mime_part(message, \"text/html\"): mime_part = get_mime_part(message, \"text/html\") html = decode_mime_part(mime_part) text_content = render_html_to_plaintext(html) else: #

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

青春壹個敷衍的年華 提交于 2019-11-26 10:45:27
问题 How do I convert a DateTime structure to its equivalent RFC 822 date-time formatted string representation and parse this string representation back to a DateTime structure in .NET? The RFC-822 date-time format is used in a number of specifications such as the RSS Syndication Format. 回答1: 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}",