473,757 Members | 10,263 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6051
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_f rom_file(xxx) (or email.message_f rom_string(xxx) )

then something like

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

if msg.is_multipar t( ):
temp_payload = msg.get_payload ()
for x in range(len(temp_ payload)):
print temp_payload[x].get_content_ty pe()
print temp_payload[x].get_filename()
print len(str(temp_pa yload[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*******@gmai l.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
26771
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 sending the email to certain email servers, the attachment section of the email gets removed and I end up with an attachment of zero kb. Other servers do accept the attachment as expected.
1
3525
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
2246
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 have a couple problems that include the magical 4mb number. 1. My problem is that when my file is over the 4 mb limit. If the 4 MB limit is met then the code on the button I use doesn't even fire (as I have code to check the file length before...
5
12731
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, in data * Module smtplib, line 312, in send * Module socket, line 1, in sendall
1
2521
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? I am using SMTP Mail Service running under IIS on win2k server to send word/excel/pdf/etc files as attachments from several in house applications
7
7645
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 can't seem to figure it out. Here is what I have so far. p = POP3("mail.server.com")
3
3012
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
1288
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 only get 1 attachment???? The script is below <?php
2
7003
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 through. I do not get any errors in my python code. I pasted my python code below. from email.MIMEBase import MIMEBase from email.MIMEMultipart import MIMEMultipart from email import Encoders
0
9489
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9298
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9906
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9885
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9737
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3399
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2698
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.