extract_msg.attachments.custom_att Module
Module contents
- class extract_msg.attachments.custom_att.CustomAttachment(msg: MSGFile, dir_: str, propStore: PropertiesStore)[source]
Bases:
AttachmentBase
The attachment entry for custom attachments.
- Parameters:
msg – the Message instance that the attachment belongs to.
dir – the directory inside the MSG file where the attachment is located.
propStore – The PropertiesStore instance for the attachment.
- getFilename(**kwargs) str [source]
Returns the filename to use for the attachment.
If the filename starts with “UnknownFilename” then there is no guarantee that the files will have exactly the same filename.
- Parameters:
contentId – Use the contentId, if available.
customFilename – A custom name to use for the file.
- regenerateRandomName() str [source]
Used to regenerate the random filename used if the attachment cannot find a usable filename.
- save(**kwargs) Tuple[SaveType, List[str] | str | None] [source]
Saves the attachment data.
The name of the file is determined by the logic of
getFilename()
. If you are a developer, ensure that you use this behavior.To change the directory that the attachment is saved to, set the value of :param customPath: when calling this function. The default save directory is the working directory.
If you want to save the contents into a
ZipFile
or similar object, either pass a path to where you want to create one or pass an instance to :param zip:. If :param zip: is an instance, :param customPath: will refer to a location inside the zip file.- Parameters:
extractEmbedded – If
True
, causes the attachment, should it be an embedded MSG file, to save as a .msg file instead of calling its save function.skipEmbedded – If
True
, skips saving this attachment if it is an embedded MSG file.
- Returns:
A tuple that specifies how the data was saved. The value of the first item specifies what the second value will be.
- property customHandler: CustomAttachmentHandler | None
The instance of the custom handler associated with this attachment, if it has one.
- property data: bytes | None
The attachment data, if any.
Returns
None
if there is no data to save.
- property randomFilename: str
The random filename to be used by this attachment.
- property type: AttachmentType
An enum value that identifies the type of attachment.