Skip to content

When saving an attachment headerFormatProperties can throw an exception when its input is None #324

Description

@programmarchy

Bug Metadata

  • Version of extract_msg: 0.38.4
  • Your python version: Python 3.9.14
  • How did you launch extract_msg?
    • My command line or
    • I used the extract_msg package

Describe the bug
headerFormatProperties can throw an exception when its input is None.

What code did you use or can we use to reproduce this error?

msg = extract_msg.Message(file_path)
for attachment in msg.attachments:
  attachment.save(customPath=output_path)

Traceback

  File "/home/user/project/process_msg_emails.py", line 46, in <module>
    extract_msg_file(file_path, output_path)
  File "/home/user/project/chronodata/emails/process_msg_files.py", line 30, in extract_msg_file
    attachment.save(customPath=output_path)
  File "/home/user/project/.venv/lib/python3.9/site-packages/extract_msg/attachment.py", line 241, in save
    self.saveEmbededMessage(**kwargs)
  File "/home/user/project/.venv/lib/python3.9/site-packages/extract_msg/attachment.py", line 254, in saveEmbededMessage
    self.data.save(**kwargs)
  File "/home/user/project/.venv/lib/python3.9/site-packages/extract_msg/message_base.py", line 902, in save
    f.write(self.getSaveBody(**kwargs))
  File "/home/user/project/.venv/lib/python3.9/site-packages/extract_msg/message_base.py", line 300, in getSaveBody
    header = self.getInjectableHeader(prefix, joinStr, suffix, formatter).encode('utf-8')
  File "/home/user/project/.venv/lib/python3.9/site-packages/extract_msg/message_base.py", line 227, in getInjectableHeader
    allProps = self.headerFormatProperties
  File "/home/user/project/.venv/lib/python3.9/site-packages/extract_msg/contact.py", line 722, in headerFormatProperties
    'Business 2': strListToStr(self.businessTelephone2Number),
  File "/home/user/project/.venv/lib/python3.9/site-packages/extract_msg/contact.py", line 699, in strListToStr
    return ', '.join(inp)
TypeError: can only join an iterable

Additional context
PR on the way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions