[Mono-list] Re: Encoding email message ??

Scott Willeke scott at willeke.com
Wed Dec 28 12:48:58 EST 2005


Roman:
Additionally there are lots of resources on the Internet for dealing 
with email. A quick search revealed a list of articles that may be of 
interest to you. A couple from the first page that were particularly 
relevant are below:
http://www.codeproject.com/csharp/despop3client.asp
http://www.eggheadcafe.com/articles/20040527.asp

I've written some some email/mime code in the past, and found that, 
despite the terseness, the POP, and MIME RFC's such as RFC2045 noted by 
Robert are invaluable.

Peter Dennis Bartok wrote:
> There's more to it then just reading the encoding from a header and pulling 
> the body through an encoder. First, anything encoded in the header itself 
> (like the Subject or Sender and Recipient names) use a special way of 
> encoding, which needs separate parsing. Then, a body can consist of multiple 
> parts, for different data types or different encodings, which requries 
> reading more headers and parsing the body into separate sections
>
> Doign what was suggested in this thread will not result in a well working 
> mail 'reader'.
>
> I suggest reading at least RFC 2045 (Multipurpose Internet Mail Extensions 
> (MIME) Part One: Format of Internet Message Bodies) and RFC 2047 (MIME 
> (Multipurpose Internet Mail Extensions) Part Three: Message Header 
> Extensions for Non-ASCII Text) or better RFC 2045-2049.
>
> The Hula project has (or at least used to have) code that did what you are 
> trying to do (take a message from the network and translate it on the fly to 
> HTML), http://www.hula-project.com/ (the mwmail module and StreamIO 
> libraries do the work)
>
> Cheers,
>   Peter
>
>
> -----Original Message-----
> From: "Robert Jordan" <robertj at gmx.net>
> To: <Mono-list at lists.ximian.com>
> Date: Wednesday, 28 December, 2005 06:50
> Subject: [Mono-list] Re: Encoding email message ??
>
>
>   
>> Hi,
>>
>> Read the headers using StreamReader (..., Encoding.ASCII).
>> If you got the encoding, just use another StreamReader, now
>> with the specified encoding.
>>
>> Robert
>>
>>     
>>> Sorry, wrong line from the code, I mean System.IO.StreamReader.
>>>
>>> System.Net.Sockets.TcpClient Server = null;
>>> System.Net.Sockets.NetworkStream NetStrm = null;
>>> System.IO.StreamReader RdStrm = null;
>>>
>>> Server = new System.Net.Sockets.TcpClient(MailFetchHost, 110);
>>> NetStrm = Server.GetStream();
>>>
>>> RdStrm = new System.IO.StreamReader(NetStrm, Encoding.?????);
>>>
>>> Robert Jordan wrote:
>>>
>>>       
>>>> Roman,
>>>>
>>>>         
>>>>> Sure, but to get to those "headers" I must already have
>>>>> System.Net.Sockets.NetworkStream with some encoding. Are you sure it
>>>>> is possible to dynamically change encoding of NetworkStream?
>>>>>           
>>>> NetworkStream doesn't have an encoding. It's transparent.
>>>>
>>>> Robert
>>>>
>>>>
>>>>         
>>>>> Robert Jordan wrote:
>>>>>
>>>>>           
>>>>>> Hi,
>>>>>>
>>>>>> Mail message headers use to have a Content-Type which also contains
>>>>>> the encoding of the message. So you have to parse the headers
>>>>>> first, then use the specified encoding to decode the message.
>>>>>>
>>>>>> Robert
>>>>>>
>>>>>>
>>>>>>             
>>>>>>> Im having similar problem. I have written my own mail server and
>>>>>>> encoding is killing me. If messages are in Unicode everything is
>>>>>>> ok, but in case of any other encoding characters just disappear. :-(
>>>>>>>
>>>>>>> If you will find some useful information how to work around this
>>>>>>> problem, please let me know.
>>>>>>>
>>>>>>> In my opinion problem is in the way how I use
>>>>>>> System.Net.Sockets.NetworkStream
>>>>>>>
>>>>>>> Salvatore Scarciglia wrote:
>>>>>>>
>>>>>>>               
>>>>>>>> Hello !
>>>>>>>> Using the System.Net.Sockets.TcpClient i'm reading my POP3 inbox
>>>>>>>> mail; I want
>>>>>>>> to convert (encode ??) the message in HTML and render it in a
>>>>>>>> gtkhtml widget
>>>>>>>> created at runtime.
>>>>>>>> It's all ok except the encoding phase. Ho can I do ? Is there a
>>>>>>>> class in the framework that can help me?
>>>>>>>>
>>>>>>>> Thanx
>>>>>>>> Salvatore
>>>>>>>> _______________________________________________
>>>>>>>> Mono-list maillist  -  Mono-list at lists.ximian.com
>>>>>>>> http://lists.ximian.com/mailman/listinfo/mono-list
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>                 
>>>>>>> _______________________________________________
>>>>>>> Mono-list maillist  -  Mono-list at lists.ximian.com
>>>>>>> http://lists.ximian.com/mailman/listinfo/mono-list
>>>>>>>
>>>>>>>               
>>>>>> _______________________________________________
>>>>>> Mono-list maillist  -  Mono-list at lists.ximian.com
>>>>>> http://lists.ximian.com/mailman/listinfo/mono-list
>>>>>>
>>>>>>
>>>>>>
>>>>>>             
>>>>> _______________________________________________
>>>>> Mono-list maillist  -  Mono-list at lists.ximian.com
>>>>> http://lists.ximian.com/mailman/listinfo/mono-list
>>>>>
>>>>>           
>>>> _______________________________________________
>>>> Mono-list maillist  -  Mono-list at lists.ximian.com
>>>> http://lists.ximian.com/mailman/listinfo/mono-list
>>>>
>>>>
>>>>
>>>>         
>>> _______________________________________________
>>> Mono-list maillist  -  Mono-list at lists.ximian.com
>>> http://lists.ximian.com/mailman/listinfo/mono-list
>>>
>>>       
>> _______________________________________________
>> Mono-list maillist  -  Mono-list at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-list
>>
>>
>>     
>
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>
>   


More information about the Mono-list mailing list