It is supposed to transfer the open file (in recording mode) to Generator(). Currently, you only pass a string to it, so it fails when it tries to call .write()in a string.
So do something like this:
import os
cwd = os.getcwd()
outfile_name = os.path.join(cwd, 'message.eml')
class Gen_Emails(object):
def SaveToFile(self,msg):
with open(outfile_name, 'w') as outfile:
gen = generator.Generator(outfile)
gen.flatten(msg)
: with open(outfile_name, 'w') as outfile outfile_name outfile. with.
os.path.join() -plattform , .
os.getcwd() . , , .