Skip to content

Commit

Permalink
PAPP-34366: working with different build envs
Browse files Browse the repository at this point in the history
  • Loading branch information
tapishj-splunk committed Sep 6, 2024
1 parent d587a59 commit a32cf2f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions gsgmail_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -961,23 +961,25 @@ def _create_message(self, sender, to, cc, bcc, subject, message_text, reply_to=N

consumer = None
if main_type in mime_consumer:
consumer = main_type[mime_consumer]
consumer = mime_consumer[main_type]
elif main_type == "application" and sub_type == "pdf":
consumer = application.MIMEApplication

self.debug_print("Content type is {0}".format(content_type))
attachment_part = None
mode = 'rb'
if main_type == "text":
mode = 'r'
if not consumer:
attachment_part = base.MIMEBase(main_type, sub_type)
with open(vault_info['path'], mode='rb') as file:
with open(vault_info['path'], mode=mode) as file:
file_content = file.read()
attachment_part.set_payload(file_content)
encoders.encode_base64(attachment_part)
else:
with open(vault_info['path'], mode='rb') as file:
with open(vault_info['path'], mode=mode) as file:
attachment_part = consumer(file.read(), _subtype=sub_type)

encoders.encode_base64(attachment_part)

attachment_part.add_header(
'Content-Disposition',
'attachment; filename={0}'.format(vault_info['name'])
Expand Down

0 comments on commit a32cf2f

Please sign in to comment.