I am currently reading file from azure blob storage and sending email. I would like to add password protection to the attachment. below is my current code which is sending an email with the attachment
import base64
from sendgrid import SendGridAPIClient
from sendgrid.helpers.mail import (Mail, Attachment, FileContent, FileName, FileType)
from azure.storage.blob import BlockBlobService
# mail details
to = To_address
from_email = From_Address
subject = Subject
content = '''
Test Content'''
# create mail object
message = Mail(
from_email = from_email,
to_emails = to,
subject = subject,
html_content = content
)
# read the content from azure blob storage
blob_service = BlockBlobService(account_name=Blob_Storage_Account, account_key=account_key)
## read the content inside blob
# read export file
export_file_data = blob_service.get_blob_to_bytes(Blob_Container, export_file_name)
export_file_mail_content = export_file_data.content
# create export file attachement
export_file_encoded = base64.b64encode(export_file_mail_content).decode()
export_file_attachment = Attachment()
export_file_attachment.file_content = FileContent(export_file_encoded)
export_file_attachment.file_type = FileType('application/txt')
export_file_attachment.file_name = FileName(export_file_name.split('/')[-1])
message.add_attachment(export_file_attachment)
# send mail with above attachment
try:
mail = SendGridAPIClient(send_grid_api_key)
response = mail.send(message)
except Exception as e:
print(str(e))
any possibilities here to add password to the file which is located in Azure storage before sending email.
I tried with pyminizip but the same is not supporting to my version 3.6. Is there any suggestion apart from open source module?