Aug-07-2023, 11:10 PM
You want to do this:
#Attach Any Files files = ['/Users/Me/Desktop/Document.pdf'] for file in files: part = MIMEBase('application', "octet-stream") part.set_payload( open(file,"rb").read() ) encoders.encode_base6[python]Your code was trying to send files named '/', 'U', 's', 'e', 'r', 's'.... If you doubt me, try this:
for file in '''/Users/Me/Desktop/Document.pdf''': print(file)Save triple quotes for multi-line quotes and docstrings, or when you have a string that contains quotes. It is odd seeing them used to quote a short string like this. It also odd seeing different quotes used for 'application' and "octet-stream". Pick a favorite quote character and use that for most strings. It makes your code easier to read.