extract_msg.attachments.emb_msg_att Module

Module contents

class extract_msg.attachments.emb_msg_att.EmbeddedMsgAttachment(msg: MSGFile, dir_: str, propStore: PropertiesStore)[source]

Bases: AttachmentBase

The attachment entry for an Embedded MSG file.

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.

Parameters:
  • contentId – Use the contentId, if available.

  • customFilename – A custom name to use for the file.

If the filename starts with “UnknownFilename” then there is no guarantee that the files will have exactly the same 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 data: MSGFile

Returns the attachment data.

property type: AttachmentType

An enum value that identifies the type of attachment.