I need to write a script which should extract the attachment from a text
file, which is saved as MIME mail message. Unfortunatelly,
Message.is_mult ipart() returns False so msg.get_payload () returns the
complete message. What I need is the attachment only. Is it possible to do
that with standard email package without the actual string level parsing?
This is how my file/message looks like:
====== start here ========
This is a multi-part message in MIME format.
------=_NextPart_000_ 0026_01C3B347.D BEA9660
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
CONTENT
signature, etc
------=_NextPart_000_ 0026_01C3B347.D BEA9660
Content-Type: application/octet-stream;
name="filename. csv"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="filen ame.csv"
10012;20031118; 292.67;4
101;23;19.98;2; 39.96
102;24;21.89;4; 87.56
------=_NextPart_000_ 0026_01C3B347.D BEA9660--
====== end here ========
So, I obviously need this part only:
10012;20031118; 292.67;4
101;23;19.98;2; 39.96
102;24;21.89;4; 87.56
Python 2.3.2 on windows.
Thanks and regards,
Davor 4 3117
"Davor Cengija" <dc************ ****@inet.hr> writes: I need to write a script which should extract the attachment from a text file, which is saved as MIME mail message. Unfortunatelly, Message.is_mult ipart() returns False so msg.get_payload () returns the
[...] This is how my file/message looks like:
====== start here ======== This is a multi-part message in MIME format.
------=_NextPart_000_ 0026_01C3B347.D BEA9660 Content-Type: text/plain;
[...]
You seem to be missing the RFC 822 headers (From, To, Subject, etc.).
John
John J. Lee wrote: "Davor Cengija" <dc************ ****@inet.hr> writes: This is a multi-part message in MIME format.
------=_NextPart_000_ 0026_01C3B347.D BEA9660 Content-Type: text/plain; [...]
You seem to be missing the RFC 822 headers (From, To, Subject, etc.).
Yes, that's true. The question is if it's easier to write a parser for that
kind of messages or to force the message producing application to output the
headers as well. We'll see...
Thanks
On Wed, 26 Nov 2003 08:06:15 +0100, Davor Cengija wrote: John J. Lee wrote: "Davor Cengija" <dc************ ****@inet.hr> writes: This is a multi-part message in MIME format.
------=_NextPart_000_ 0026_01C3B347.D BEA9660 Content-Type: text/plain; [...]
You seem to be missing the RFC 822 headers (From, To, Subject, etc.).
Yes, that's true. The question is if it's easier to write a parser for that kind of messages or to force the message producing application to output the headers as well. We'll see...
You have a third option, which I would try if you can't get the
message producer to do it correctly: slap some RFC822 headers on the
beginning, and then ignore them in the parsed message object. After
all, if the rest of the data is correctly formatted, use the existing
tested MIME parser. Prepending some "bogus" RFC822 headers would be
rather trivial to do.
-D
--
"Piracy is not a technological issue. It's a behavior issue."
--Steve Jobs
www: http://dman13.dyndns.org/~dman/ jabber: dm**@dman13.dyn dns.org
Derrick 'dman' Hudson <dm**@dman13.dy ndns.org> writes: On Wed, 26 Nov 2003 08:06:15 +0100, Davor Cengija wrote:
[...] You seem to be missing the RFC 822 headers (From, To, Subject, etc.).
Yes, that's true. The question is if it's easier to write a parser for that kind of messages or to force the message producing application to output the headers as well. We'll see...
You have a third option, which I would try if you can't get the message producer to do it correctly: slap some RFC822 headers on the beginning, and then ignore them in the parsed message object. After
[...]
Or read the docs & code for the email module, to figure out how to
persuade it to take the messages without the headers.
John This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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.
|
by: Paul Schmidt |
last post by:
Dear list:
I am new to python, and I am trying to figure out the short answer on
something.
I want to open a POP3 mailbox, read the enclosed mail using the POP3
module, , and then process it using the email module.
Environment Python 2.3.4, Mandrake Linux 9.0 patched up the wazoo...
|
by: Joh |
last post by:
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
|
by: Arenz, Ralph |
last post by:
hi all,
my problem is to get a tiff-file-attachment out of an email sent by a
fax-server.
When i try this with "get_payload(decode='True')" i get additional
informations, looks like binary-mixed header-information, enveloping the
tiff-data.
I tried the following: Sending the email from outlook to a postfix-user and
a file on the postfix-host as well. The file shows the stucture mentioned
|
by: Dave G |
last post by:
I'm writing a function to look for particular emails in my Inbox and
when it finds one it copies the attachment to a folder and then deletes
the email. It spots the email by looking for certain text in the
subject line. Here's a code fragment:
Dim appOutlook As Outlook.Application
Dim mpiFolder As MAPIFolder
Dim msgMail As MailItem
Dim strAQSPath As String
Dim strSubject As String
| |
by: 叮叮当当 |
last post by:
hi, all
when a email body consist with multipart/alternative, i must know when
the boundary ends to parse it,
but the email lib have not provide some function to indicate the
boundary end, how to solve it ?
thanks.
|
by: Sergey Dorofeev |
last post by:
Hello.
Why does not work?
--------------
import email.message
import smtplib
import time
m=email.message.Message()
|
by: Steven Allport |
last post by:
I am working on processing eml email message using the email module (python
2.5), on files exported from an Outlook PST file, to extract the composite
parts of the email. In most instances this works fine, the message is read
in using message_from_file, is_multipart returns True and I can process each
component and extract message attachments.
I am however running into problem with email messages that contain emails
forwarded as...
|
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
|
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, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look !
Part I. Meaning of...
|
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...
| |
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,...
|
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...
|
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 projectplanning, coding, testing, and deploymentwithout 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...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |