Help with ASCII (UNIX<->DOS)

CeK! cend2 at
Wed Sep 19 13:51:45 CEST 2001

Hi!, first of all I'd like to thank U for reading this, thanks! :)
I'm new to PYTHON, & I'm really excited about the many things that can
be done (specially how FAST), but as with every newbie, I want to do
lots of things & for now, tend 2 get lost.

Now with the problem:
I've made a simple Python prog that connects to an IMAP server ,
checks the accounts for new mails, & if it finds so, it retrieves
them, & saves them 2 a file...
The problem is that with these lines of code, 

    typ, data = M.fetch(num, '(RFC822)')
    WriteEmail('%s\n' % (data[0][1]))

def WriteEmail(Uname,EData):
    "Writes data of an E-Mail 2 a file"
    Efilename = DestMDaemon + Uname + '\\' + 'md51000' +
strftime("%H%M%S") + '.msg'
    print 'Saving Email to : ' + Efilename
    f=open(Efilename,'w')        # Also tried 'a' 'wb'

the saved file is not in DOS notation, it has (HEX) 0D 0D 0A ... hummm
this code, renders the file unreadable to the email client... (big
I read about UNICODE & conversions... but I feel lost...
I need 2 create a file with standard DOS (ASCII) with 0D 0A (CRLF).
I'm sure it's a newbie question, but time presses me, that's why I'm
posting in the Ngroup, hope nobodey gets bothered. ;)

Thanks in advance for your help & understanding.

More information about the Python-list mailing list