473,545 Members | 1,947 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding Multiple Attachments to SMTP mail (msg.add_header )

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
header.

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',
filename=ATTsel ection[doatt])
doatt = doatt + 1
outer.attach(ms g)

.......
body = MIMEText(Text)
outer.attach(bo dy)

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!

Thanks,
Ed

Mar 10 '06 #1
2 3962
EdWhyatt wrote:
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
header.

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',
filename=ATTsel ection[doatt])
doatt = doatt + 1
outer.attach(ms g)

......
body = MIMEText(Text)
outer.attach(bo dy)

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!

Thanks,
Ed


Take a look at the following:

http://motion.sourceforge.net/related/send_jpg.py

http://aspn.activestate.com/ASPN/Coo...n/Recipe/52243

Larry Bates
Mar 10 '06 #2
On 10 Mar 2006 06:08:37 -0800, rumours say that "EdWhyatt"
<ed*******@gmai l.com> might have written:
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',
filename=ATTse lection[doatt])
doatt = doatt + 1
outer.attach(ms g)

......
body = MIMEText(Text)
outer.attach(bo dy)

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


The {doatt = doatt + 1} line is unneeded in the {for doatt in} loop. This
*might* be your problem, I didn't delve any deeper.
--
TZOTZIOY, I speak England very best.
"Dear Paul,
please stop spamming us."
The Corinthians
Mar 18 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
10948
by: Bill | last post by:
I am trying to have the capability to email attachments. Specifically I want to be able to email a specific attachment that I name that may be a PDF document, text doc, etc. I already have a working piece of code that emails jpg attachments but does not work with any other types of attachments. Could someone tell me how to modify this code to...
0
1369
by: bill ramsay | last post by:
Hello I am writing a program that sends simple text files to a remote device. the files have to be in the format textX.dat where X = numbers in the range 0 up to 10 depending upon the situation. these files are stored in a directory called attachments. The files themselves are single line affairs in ascii.
2
14671
by: Alex Hunsley | last post by:
I'm using the smtp module to send emails from python. I would like to specify several recipients of the email like follows: msg = MIMEText(time.ctime("Body text of email") me = 'my@sending.address' you = 'recipient1@some.where,recipient2@some.where' msg = '*** Carwatch alert' msg = me msg = you
2
1486
by: larry mckay | last post by:
I'm trying to send mail using the mail.smptserver, mailmessage, mailattachment objects I'm having trouble assigning an attachment to before doing an smpt.send using vb.net does anyone have any coding samples on how to programatically add mail attachments using .net
4
1930
by: Russell Bungay | last post by:
Hello all, I have written a short function, based on a recipe in the Python Cookbook, that sends an e-mail. The function takes arguments that define who the e-mail is to, from, the subject, the body and an optional list of attachments. The function works also perfectly, bar one slight problem. If you attempt to send an e-mail with just...
5
2357
by: Robert Dufour | last post by:
I am trying to use framework 1.1 - stuck with it. to send emails from a windows form application. The email messages can have attachments, usually two and they can be either text or sounds (wav files) or images (bmp, gif or tiff) I can send the email messages OK but the attachments are giving me grief. Can anyone provide some code that...
1
399
by: Steve Holden | last post by:
I'm having some trouble getting attachments right for all recipients, and it seems like Apple's mail.app is the pickiest client at the moment. It doesn't handle attachments that both Thunderbird and Outlook find perfectly acceptable. Since the code I'm using is currently ugly and embedded, before I trim it down for posting could anyone...
2
5249
by: Robson Siqueira | last post by:
Folks, I've been experiencing a weird problem. I have a web service which sends an email after its processing. The email always has an PDF attachment on it. The PDF size vary overtime. The problem is that everytime the PDF size is equal to or less than 200 KB, the email is just not being sent. There are no error messages, nothing. Here...
1
3559
by: Whyatt | last post by:
Hi all, I'm trying to create a message using SMTP Mail through Python with a message Importance of either 0 (Low) or 2 (High). If I do outer.Add_header('Importance', '0') it is ignored. If I do uter.Replace_header('Importance', '0') I get the error below. Traceback (most recent call last): File "#####", line 840, in <module>
0
7484
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7415
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7928
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
7440
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
7775
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...
1
5344
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4963
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1902
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
1
1030
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.