On a Unix server, I am using smtplib in python to send an email to myself ; the email also contains a unix file attachment. I use outlook client to view the email and when I open the file, it does not display correctly due to differences in Unix and DOS format.
Is there anyway using smtplib to send the Unix file in DOS format ?
I do not want to use unix2dos as I do not want to create/modify files on the filesystem.
Editing the question to include changes based on suggestions from senior members
Since I have been asked to modify the file, need to know if there is a simpler way to do that. I am not well versed with Python so please bear with me. I have tried a few variations of the following but none have worked. My requirement is that I do not want to write to the file system. I want to save the changes into a variable in memory.
import string fo=open(filename,"r") filecontent=fo.readlines() for line in filecontent: line = string.replace(line,"\n","\r\m")