473,569 Members | 2,383 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Password Protection to Email attachment

1 New Member
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 SendGridAPIClie nt
from sendgrid.helper s.mail import (Mail, Attachment, FileContent, FileName, FileType)
from azure.storage.b lob import BlockBlobServic e

# 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 = BlockBlobServic e(account_name= Blob_Storage_Ac count, account_key=acc ount_key)
## read the content inside blob
# read export file
export_file_dat a = blob_service.ge t_blob_to_bytes (Blob_Container , export_file_nam e)
export_file_mai l_content = export_file_dat a.content


# create export file attachement
export_file_enc oded = base64.b64encod e(export_file_m ail_content).de code()
export_file_att achment = Attachment()
export_file_att achment.file_co ntent = FileContent(exp ort_file_encode d)
export_file_att achment.file_ty pe = FileType('appli cation/txt')
export_file_att achment.file_na me = FileName(export _file_name.spli t('/')[-1])
message.add_att achment(export_ file_attachment )


# send mail with above attachment
try:
mail = SendGridAPIClie nt(send_grid_ap i_key)
response = mail.send(messa ge)
except Exception as e:
print(str(e))
Jun 10 '21 #1
1 2817
dev7060
639 Recognized Expert Contributor
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
3090
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 step by step tutorial on how to set this up as i've never used php before
6
3341
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 htaccess which is fine but can only protect one directory unless I put htaccess on each directory which I think is a bit long winded, but is there any...
7
2140
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 name="submit" type="submit"> </form> <?php die; }
2
2567
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 and jumping directing into an area they may not have access to bypassing the login page.
7
1825
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
1662
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 quick test sites or temporary stuff I use the Windows Network Authentication provided by my web host. A whole folder is protected at once which is very...
0
1080
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 application. The workgroup information file is missing or opened exclusively by another user. Plz Help me....
2
3304
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 protection. I would like to know it is possible or not.
0
7926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8132
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7678
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7982
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6286
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3656
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3644
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2116
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
944
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.