snippet
payload = {}
try:
message = email.message_from_string(message)
messageHeader = dict(message._headers)
addressFrom = messageHeader["From"]
addressReply = messageHeader.get("Reply-To")
messageId = messageHeader.get("Message-ID")
if messageId is not None:
if addressFrom is not None:
if addressReply is not None:
if message.is_multipart:
count = 0
for partition in message.walk():
if partition.get_type() == "application/vnd.ms-word":
payload[partition.get_filename()] =
partition.get_payload(count,True)
count += 1
message.close()
except:
print "Houston we have a problem"
--- end of snippet
I've wrote the above segment but haven't tried running it yet because I'm
unclear about the api for message.
In the get_payload api it says if you don't pass parameters it returns a
list of messages (1 for each part)
it also states a lot of other stuff which I found to be a bit confusing.
If I use it as above, is it going to return a string? or message object?
If its a message object, what does it mean to have an decoded message object
vs an encoded message object?
finally I want to associate each part's original name with the part (whether
actual data or a message object) so I was thinking of using a dictionary
approach
David
-------
Tracfone: http://cellphone.duneram.com/index.html
Cam: http://www.duneram.com/cam/index.html
Tax: http://www.duneram.com/index.html
__________________________________________________ _______________
Getting married? Find great tips, tools and the latest trends at MSN Life
Events. http://lifeevents.msn.com/category.aspx?cid=married 2 2816
On Thu, 03 Jun 2004 18:31:54 +0000, "David Stockwell"
<wi*******@hotmail.com> wrote: snippet
[snippet]I've wrote the above segment but haven't tried running it yet because I'm unclear about the api for message.
Ok, let's stop here.
What?!
Has Ernst Stavro Blofeld attached some doomsday device to your stack
trace?
You've got an interpreter, use it! Go man! Go!
Anyway, I'll poke around a little for you. I put your post into a
file named message.txt headers and all.
$ python
Python 2.3.3 (#1, Apr 30 2004, 08:54:23)
[GCC 3.3.1 (cygming special)] on cygwin
Type "help", "copyright", "credits" or "license" for more information. import email m = email.message_from_file(file('message.txt')) m.keys()
['Path', 'From', 'Newsgroups', 'Subject', 'Date', 'Organization',
'Lines', 'Message-ID', 'NNTP-Posting-Host', 'Mime-Version',
'Content-Type', 'X-Trace', 'X-Complaints-To', 'NNTP-Posting-Date',
'To', 'X-Originating-IP', 'X-Originating-Email', 'X-Sender',
'X-OriginalArrivalTime', 'X-Spam-Status', 'X-BeenThere',
'X-Mailman-Version', 'Precedence', 'List-Id', 'List-Unsubscribe',
'List-Archive', 'List-Post', 'List-Help', 'List-Subscribe', 'Xref'] m['Date']
'Thu, 03 Jun 2004 18:31:54 +0000' m.get_content_type()
'text/plain' s = m.get_payload() print s
snippet
payload = {}
try:
message = email.message_from_string(message)
messageHeader = dict(message._headers)
[... etc...] type(s)
<type 'str'> for p in m.walk():
.... print p.get_content_type()
....
text/plain dir(m)
['__contains__', '__delitem__', '__doc__', '__getitem__', '__init__',
'__len__', '__module__', '__setitem__', '__str__', '_charset',
'_default_type', '_get_params_preserve', '_headers', '_payload',
'_unixfrom', 'add_header', 'add_payload', 'as_string', 'attach',
'del_param', 'epilogue', 'get', 'get_all', 'get_boundary',
'get_charset', 'get_charsets', 'get_content_charset',
'get_content_maintype', 'get_content_subtype', 'get_content_type',
'get_default_type', 'get_filename', 'get_main_type', 'get_param',
'get_params', 'get_payload', 'get_subtype', 'get_type',
'get_unixfrom', 'has_key', 'is_multipart', 'items', 'keys',
'preamble', 'replace_header', 'set_boundary', 'set_charset',
'set_default_type', 'set_param', 'set_payload', 'set_type',
'set_unixfrom', 'values', 'walk']
etc.. etc...
That should answer a few of your questions. Do not fear the stack
trace, it is your friend.
<{{{*>
On Friday 04 Jun 2004 06:15, fishboy wrote: What?! Has Ernst Stavro Blofeld attached some doomsday device to your stack trace? You've got an interpreter, use it! Go man! Go!
+1 QOTW This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Gary Smith |
last post by:
I'm tring to send out a dual encoded message in html and text message.
From everything that I have read and seen as incoming messages this
should work but it doesn't. Any ideas?
TIA,
Gary...
|
by: Alberto |
last post by:
I am struggling with the php mail function so to allow a multipart mime
settings where both the message and any set of attachments can be
allowed.
Teorically, I'd know how to do. I build up my...
|
by: Zev Steinhardt |
last post by:
I'm trying to use Mime::Lite to send out multipart messages. So far,
it all seems to work well except for one small part.
I want to display a "real name" along with the email address when I...
|
by: Imran |
last post by:
Hi,
Please bear with me as I have only 1 weeks .NET experience.
I am using VB.NET to write a stand-alone client application that
connects to a Web service. I successfully send a request for a...
|
by: Nobody |
last post by:
I have an application that processes MIME messages. It reads a message from a file,
looks for a text/html and text/plain parts in it, performs some processing on these
parts, and outputs the new...
|
by: b. dougherty |
last post by:
Greetings all- I am trying to extract subject headers from emails that
have been saved as text files. The subject headers are in MIME UTF-8
format, and so they appear like this:
subject:...
|
by: ceh |
last post by:
Hi, on windows xp I'm using
xampp v 1.6.4
I'm trying to send mail. The mail always sends, but the multipart
sections are broken. Essentially, I want to send an html email that
has a link...
|
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...
|
by: Ron Garret |
last post by:
I'm writing a little HTTP server and need to parse request content that
is mime-encoded. All the MIME routines in the Python standard library
seem to have been subsumed into the email package,...
|
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...
|
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,...
|
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...
|
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,...
|
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...
|
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...
|
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...
|
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...
|
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 ...
| |