For some pdf attachments the filename field is empty. This is because sometimes the file name is indicated in the content-type field.
https://docs.python.org/3/library/email.message.html#email.message.EmailMessageget_filename(failobj=None)¶
Return the value of the filename parameter of the Content-Disposition header of the message. If the header does not have a filename parameter, this method falls back to looking for the name parameter on the Content-Type header. If neither is found, or the header is missing, then failobj is returned. The returned string will always be unquoted as per email.utils.unquote().
For some pdf attachments the filename field is empty. This is because sometimes the file name is indicated in the content-type field.
https://docs.python.org/3/library/email.message.html#email.message.EmailMessage get_filename(failobj=None)¶ Return the value of the filename parameter of the Content-Disposition header of the message. If the header does not have a filename parameter, this method falls back to looking for the name parameter on the Content-Type header. If neither is found, or the header is missing, then failobj is returned. The returned string will always be unquoted as per email.utils.unquote().