|
1 | 1 | class Attachment(object): |
2 | 2 | """An attachment to be included with an email.""" |
3 | 3 |
|
4 | | - def __init__(self): |
5 | | - """Create an empty Attachment.""" |
| 4 | + def __init__(self, content=None, type_=None, filename=None, disposition=None, content_id=None): |
| 5 | + """Create an Attachment |
| 6 | +
|
| 7 | + :param content: The Base64 encoded content of the attachment |
| 8 | + :type content: string, optional |
| 9 | + :param filename: The filename of the attachment |
| 10 | + :type filename: string, optional |
| 11 | + :param disposition: The content-disposition of the attachment, specifying display style. |
| 12 | + Specifies how you would like the attachment to be displayed. |
| 13 | + - "inline" results in the attached file being displayed automatically |
| 14 | + within the message. |
| 15 | + - "attachment" results in the attached file requiring some action to |
| 16 | + display (e.g. opening or downloading the file). |
| 17 | + If unspecified, "attachment" is used. Must be one of the two choices. |
| 18 | + :type disposition: string, optional |
| 19 | + :param content_id: The content id for the attachment. |
| 20 | + This is used when the disposition is set to "inline" and the attachment |
| 21 | + is an image, allowing the file to be displayed within the email body. |
| 22 | + :type content_id: string, optional |
| 23 | + """ |
6 | 24 | self._content = None |
7 | 25 | self._type = None |
8 | 26 | self._filename = None |
9 | 27 | self._disposition = None |
10 | 28 | self._content_id = None |
11 | 29 |
|
| 30 | + if content is not None: |
| 31 | + self.content = content |
| 32 | + |
| 33 | + if type_ is not None: |
| 34 | + self.type = type_ |
| 35 | + |
| 36 | + if filename is not None: |
| 37 | + self.filename = filename |
| 38 | + |
| 39 | + if disposition is not None: |
| 40 | + self.disposition = disposition |
| 41 | + |
| 42 | + if content_id is not None: |
| 43 | + self.content_id = content_id |
| 44 | + |
12 | 45 | @property |
13 | 46 | def content(self): |
14 | 47 | """The Base64 encoded content of the attachment. |
|
0 commit comments