473,287 Members | 1,964 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

Password Protection to Email attachment

Hi All,

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 email with attachement

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))
Jun 10 '21 #1
1 2784
dev7060
626 Expert 512MB
I would like to add password protection to the attachment.
Encrypt it before attaching.
Jun 13 '21 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Boris | last post by:
I am wanting to set up password protection for an area on my website, so only our members can access this area. I am needing to do this using php as the domain hosts do not support asp I need a...
6
by: Lou | last post by:
Please can someone put me out my misery! Im trying to find a multiple user/password protection script that will redirect the specific user to a specific directory. At the moment I have set up...
7
by: juglesh | last post by:
<body><div align="center"> <?php if (!isset($password)){ ?><form action="<?php $_SERVER; ?>" method="post"> type password here&nbsp;<input name="password" type="text" size="8"> then <input...
2
by: chris | last post by:
Hi, I will be looking to use gatekeeper or some other javascript method of password protection but... Once there I need a way of resticting access to a page to stop someone from bookmarking...
7
by: Borked Pseudo Mailed | last post by:
Seeking feedback on Password Protection via Java/JavaScript ONLY (no cgi): SEE: http://online_tools.home.att.net/tools.html *AND* http://online_tools.home.att.net/extraCode.htm Thanks.
0
by: btopenworld | last post by:
Hi I have been using two forms of password protection: A) On working web sites I use an ASP script that is included in every page requiring protection: uses session - works fine B) On...
0
by: vidhyapriya | last post by:
How do I Compress my Database with password (MS Access Database). Script Below was done if my database unlock with password protection, but when it lock... I've got an error : Cannot start your...
2
by: foekall | last post by:
Dear All, In my office is using Windows Server 2003 with IIS 6.0. When I access IIS 6.0 from internet browser I always need to type user name and password. So, I want to access without password...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.