Adding Multiple Attachments to SMTP mail (msg.add_header)

EdWhyatt ed.whyatt at
Fri Mar 10 15:08:37 CET 2006

Hi all, I hope there is someone out there who can help me out - it has
to be something obvious.

I am simulating mail traffic, and want to include multiple attachments
to my mail. I have created a temporary array containing a number of
files - for now just 2.

Debugging my code, I can see that I am correctly storing the files in
the array, and then 1 by 1 adding one file at a time to the message

When the program is complete, the resultant mail has 2 attachments, as
hoped. However, it is the second file attached twice, rather than the
two unique files.

I attach my code for passing the information to  msg.add_header:

(AttNum = 2)

            for doatt in range(AttNum):
                msg.add_header('Content-Disposition', 'attachment',
                doatt = doatt + 1

    body = MIMEText(Text)

Like I said, it is correctly sending the 2 seperate files from my
ATTselection array, but ultimately attaching the last file twice.

If anyone can help/suggest something please please let me know!


More information about the Python-list mailing list