MCPcopy Create free account
hub / github.com/ActiveState/code / attach_file

Function attach_file

recipes/Python/578807_Sending_Email/recipe-578807.py:107–110  ·  view source on GitHub ↗
(msg, afile)

Source from the content-addressed store, hash-verified

105# attach file
106# takes the message and a file name and attaches the file to the message
107def attach_file(msg, afile):
108 part = MIMEApplication(open(afile, "rb").read());
109 part.add_header('Content-Disposition', 'attachment', filename=afile);
110 msg.attach(part);
111
112#to be tested...
113compose_email(['cpt@thelivingpearl.com','',''],

Callers 1

compose_emailFunction · 0.85

Calls 4

add_headerMethod · 0.80
openFunction · 0.50
readMethod · 0.45
attachMethod · 0.45

Tested by

no test coverage detected