Hi Team, Thanks for reply.
Yes, I can give you fair idea what I am doing here hdr = email.message_from_string( smtp_header_string ) tmpContentType = msg['Content-Type'] del msg['Content-Type'] for key in hdr.keys(): values = hdr.get_all(key) if values != None: if key not in msg: for value in values: msg.add_header(key,value) I have header for the mail in smtp_header_string. I want to generate RFC2822 file by using this. I found out solution for this. Header for which I am geeting failure has one line which is not valid header line. So by using following regular expression headerRE = re.compile(r'^(From |[\041-\071\073-\176]{2,}:|[\t ])') I parsed every line from header and if line doesn't satisfy this RE, I just dropped that line from header and then I passed this header string to email.message_from_string() function. Rest all is same. It works fine now. Thank you very much for your reply. Thanks and Regards Vinayakc -- http://mail.python.org/mailman/listinfo/python-list