473,586 Members | 2,863 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 3967
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
10951
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
1372
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
14673
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
1488
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
1934
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
2359
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
5255
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
3587
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
7911
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
8200
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
8338
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
7954
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
8215
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
5710
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
3836
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
3864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1448
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.