Sending Error when attaching files

Joined
Aug 7, 2023
Messages
1
Reaction score
0
I’m encountering a sending error when trying to attach one or more files to an email using Python 3.

The script works perfectly with embedded images, styled text,…etc. It’s the block of code below that makes it fail if a document is listed. In this example, the file does exist (in this case on the Mac Desktop) and the path is correct. The script runs to conclusion and appears to send the email but the email fails to go through. If I omit this block, the email goes through with any included images, so the whole issue appears to be here.

The document name and path is provided in a variable and it may be one, none or several attachments in the variable.

The script runs completely but shows Sending Error when completed IF, and only if, I've attempted to have a file attachment included.

Code:
#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]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top