473,396 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to get size of email attachment

Joh
hello,

i'm looking for a way to get total size of an email (with its attached
files) using library such as poplib, or ?

can someone help me or give me an url from where to start ?

thx
Jul 18 '05 #1
3 6002
Joh wrote:
i'm looking for a way to get total size of an email (with its attached
files) using library such as poplib, or ?

can someone help me or give me an url from where to start ?


Looking in the docs for poplib, I found this:
http://docs.python.org/lib/pop3-objects.html

It describes how using .list() should provide you with results in
the form (response, ['mesg_num octets', ...]). The word "octets"
here refers to the number of bytes, essentially, in each message.

-Peter
Jul 18 '05 #2
On 30 Aug 2004 12:05:18 -0700, Joh <jo******@yahoo.fr> wrote:
hello,

i'm looking for a way to get total size of an email (with its attached
files) using library such as poplib, or ?

can someone help me or give me an url from where to start ?


thinking aloud and off the top of my head , you could try the email
module (python docs)

import email

msg = email.message_from_file(xxx) (or email.message_from_string(xxx) )

then something like

for part in msg.walk():
length = len(str(part))
fname = part.get_filename()
or

if msg.is_multipart( ):
temp_payload = msg.get_payload()
for x in range(len(temp_payload)):
print temp_payload[x].get_content_type()
print temp_payload[x].get_filename()
print len(str(temp_payload[x]))

Remember any size you get will be the size of the attachment whilst
its encoded into a mime object, which won't be the same as the size
of the file on disk.

I'm not sure the above will work, but its in the right ball park, If
you don't have any luck post back and I'll look into it next time I'm
in the office and have python docs easily to hand.
Jul 18 '05 #3
On Mon, 30 Aug 2004 22:08:42 +0100, Tim Williams (gmail)
<td*******@gmail.com> wrote:
On 30 Aug 2004 12:05:18 -0700, Joh <jo******@yahoo.fr> wrote:
hello,

i'm looking for a way to get total size of an email (with its attached
files) using library such as poplib, or ?

can someone help me or give me an url from where to start ?


thinking aloud and off the top of my head , you could try the email
module (python docs)


I put a recipe up on the Python cookbook for stripping out attachments
from an email message - you could adapt that to measure the sizes of
the attachments pretty easily.

http://aspn.activestate.com/ASPN/Coo.../Recipe/302086
Jul 18 '05 #4

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

Similar topics

4
by: Wald | last post by:
Hello group, I've got a script here that sends emails with an attachment to an email address that is retrieved from an html form. The email sending code is include below. The problem: when...
1
by: abracad | last post by:
I'd like to add a form that will email a file attachment to me. Can anyone recommend a decent free script? Thanks
1
by: BTHOMASinOHIO | last post by:
I am confussed on what the heck is going on ?! I have an HTML INPUT File Box on an Email Piece of an application. I know that File Size is set to 4MB in the WebConfig File and that is fine, but I...
5
by: morphex | last post by:
Hi, I have an email that's in the utf-8 encoding, and I'm getting this error message when I try to send it using smtplib: * Module smtplib, line 688, in sendmail * Module smtplib, line 485,...
1
by: Lelle | last post by:
Sorry for crossposting - sent to wrong group first hello ! does anyone have more information regarding this issue? http://www.systemwebmail.com/faq/2.3.aspx a.. Attachment Size Limit? ...
7
by: erikcw | last post by:
Hi all, I'm trying to extract zip file (containing an xml file) from an email so I can process it. But I'm running up against some brick walls. I've been googling and reading all afternoon, and...
3
by: jambonjamasb | last post by:
Hi I have two tables: email_tbl Data_table Data table is is used to create a Form Data_form
0
by: tourerukcom | last post by:
Hi i wonder if any one can help. I have script that that sends a email with mulitple attachments. It seems to work fine as i get the email with the attachments on. But other people i send it to...
2
by: Eric E | last post by:
Hello All - I am using python to send an email with a large zip file as an attachment. I successfully sent a 52M attachment. If I try to send a 63M attachment or larger, the message never gets...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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...

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.