extract_msg.attachments.custom_att_handler Package
Subpackages/Submodules
Package contents
- class extract_msg.attachments.custom_att_handler.CustomAttachmentHandler(attachment: AttachmentBase)[source]
Bases:
ABC
A class designed to help with custom attachments that may require parsing in special ways that are completely different from one another.
- getStream(filename: str | List[str] | Tuple[str]) bytes | None [source]
Gets a stream from the custom data directory.
- getStreamAs(streamID: str | List[str] | Tuple[str], overrideClass: Type[_T] | Callable[[Any], _T]) _T | None [source]
Returns the specified stream, modifying it to the specified class if it is found.
- Parameters:
overrideClass – Class/function to use to morph the data that was read. The data will be the first argument to the class’s __init__ function or the function itself, if that is what is provided. If the value is None, this function is not called. If you want it to be called regardless, you should handle the data directly.
- abstract classmethod isCorrectHandler(attachment: AttachmentBase) bool [source]
Checks if this is the correct handler for the attachment.
- abstract generateRtf() bytes | None [source]
Generates the RTF to inject in place of the objattph tag.
If this function should do nothing, returns
None
.
- property attachment: AttachmentBase
The attachment this handler is associated with.
- abstract property data: bytes | None
Gets the data for the attachment.
If an attachment should do nothing when saving, returns
None
.
- abstract property name: str | None
Returns the name to be used when saving the attachment.
- abstract property obj: object | None
Returns an object representing the data.
May return the same value as :property data:.
If there is no object to represent the custom attachment, including
bytes
, returnsNone
.
- property objInfo: ODTStruct | None
The structure representing the stream “x03ObjInfo”, if it exists.
- property ole: OleStreamStruct | None
The structure representing the stream “x01Ole”, if it exists.
- property presentationObjs: Dict[int, OLEPresentationStream] | None
Returns a dict of all presentation streams, as bytes.
- class extract_msg.attachments.custom_att_handler.LinkedObjectAttachment(attachment: AttachmentBase)[source]
Bases:
CustomAttachmentHandler
A link to an Outlook object.
Not positive I understand what this attachment type is, but this seems to be the most likely name. Contains presentation data about how to render it as well as properties with data that link to it. It looks similar to what the documentation for Journal specifies would be it’s custom attachment type, however some small details don’t perfectly add up.
I’ve also only seen this on Journal objects thus far.
- classmethod isCorrectHandler(attachment: AttachmentBase) bool [source]
Checks if this is the correct handler for the attachment.
- generateRtf() bytes | None [source]
Generates the RTF to inject in place of the objattph tag.
If this function should do nothing, returns
None
.
- property data: None
Gets the data for the attachment.
If an attachment should do nothing when saving, returns
None
.
- property mailMsgAttMsg: EntryID | None
The EntryID linked Message object, required only if the mailMsgAttSrchKey property is None.
- property mailMsgAttSrchFld: EntryID | None
The object EntryID of the Sent Items special folder of the linked Message object.
- property mailMsgAttSrchKey: bytes | None
The search key for the linked message object, required only if mailMsgAttMsg is None.
- property name: None
Returns the name to be used when saving the attachment.
- property obj: None
Returns an object representing the data.
May return the same value as :property data:.
If there is no object to represent the custom attachment, including
bytes
, returnsNone
.
- class extract_msg.attachments.custom_att_handler.OutlookImageDIB(attachment: AttachmentBase)[source]
Bases:
CustomAttachmentHandler
Custom handler for a special attachment type, a Device Independent Bitmap stored in a way special to Outlook.
- classmethod isCorrectHandler(attachment: AttachmentBase) bool [source]
Checks if this is the correct handler for the attachment.
- generateRtf() bytes | None [source]
Generates the RTF to inject in place of the objattph tag.
If this function should do nothing, returns
None
.- Raises:
DependencyError – PIL or Pillow could not be found.
- property data: bytes
Gets the data for the attachment.
If an attachment should do nothing when saving, returns
None
.
- property name: str
Returns the name to be used when saving the attachment.
- property obj: bytes
Returns an object representing the data.
May return the same value as :property data:.
If there is no object to represent the custom attachment, including
bytes
, returnsNone
.
- class extract_msg.attachments.custom_att_handler.OutlookImageMetafile(attachment: AttachmentBase)[source]
Bases:
CustomAttachmentHandler
Custom handler for a special attachment type, a Device Independent Bitmap stored in a way special to Outlook.
- classmethod isCorrectHandler(attachment: AttachmentBase) bool [source]
Checks if this is the correct handler for the attachment.
- generateRtf() bytes | None [source]
Generates the RTF to inject in place of the objattph tag.
If this function should do nothing, returns
None
.- Raises:
DependencyError – PIL or Pillow could not be found.
- property data: bytes
Gets the data for the attachment.
If an attachment should do nothing when saving, returns
None
.
- property name: str
Returns the name to be used when saving the attachment.
- property obj: bytes
Returns an object representing the data.
May return the same value as :property data:.
If there is no object to represent the custom attachment, including
bytes
, returnsNone
.
- extract_msg.attachments.custom_att_handler.getHandler(attachment: AttachmentBase) CustomAttachmentHandler [source]
Takes an attachment and uses it to find the correct handler.
Returns an instance created using the specified attachment.
- Raises:
NotImplementedError – No handler could be found.
ValueError – A handler was found, but something was wrong with the attachment data.
- extract_msg.attachments.custom_att_handler.registerHandler(handler: Type[CustomAttachmentHandler]) None [source]
Registers the CustomAttachmentHandler subclass as a handler.
- Raises:
TypeError – The handler was not a subclass of CustomAttachmentHandler.