Read through an email and parse it into strings with python - python

I am wondering if it is possible to read through an email and parse the subject of the email into a string. I have a device that sends an email to specific inbox every time there is an error with the device. I want a script to read through the email as soon as it arrives in the inbox and get the device ID from the subject line and store it into a string. I was thinking I could use python because there are email modules for it, and it is what I'm most comfortable with. Would this be possible in Python? Or any other language for that matter? I have looked online, but I could not find anything that pertains to what I want it to do. Is this even possible? Thanks!

Related

Reply to an Outlook email in the same email history/conversation using the MessageID and Win32com module in Python

So I know how to look through the inbox (or any other folder) and find emails to reply to. However in my case, I have a .msg email file from which I extract the MessageID, and I'm looking to use win32com module to reply to that specific email.
I precisely need the sent email to appear in the same email thread/history/conversation as the email being responded to. I've tried setting the PR_IN_REPLY_TO_ID property to the MessageID of the msg file (PR_INTERNET_MESSAGE_ID) using the following code:
mail.PropertyAccessor.SetProperty("http://schemas.microsoft.com/mapi/proptag/0x1042001F", msg.messageId)
But this did not show the received email in the same email thread/history/conversation. My main expectation is for the received email to show like this just above the email being replied to:
Thank you for your help.
The mail object properties ConversationIndex and ConversationTopic give you an easy way to organize and display messages. Rather than simply grouping messages by subject, time received, or sender, you can show conversational relationships among messages. The ConversationTopic property is a string that describes the overall subject of the conversation. All messages within the same conversation use the same value for the ConversationTopic property. The ConversationIndex property is a hexadecimal string that you can use to represent the relationships between the messages in the thread. Each message in the conversation should have a different ConversationIndex property. Read more about that in the Working with Conversations article.
I'd suggest checking message headers on every incoming email put into the same conversation, all the required information can be found there.

Python / Email processing: How to get the date an attachment was created?

I have a Python program that will read an Outlook inbox using these Python libraries:
1. IMAPClient
2. email
I want to know if it is possible to get the date the email attachment was created.
I don't see anything in email headers that stand out. I can get the date an email was sent (or forwarded), but it is the case when an email is forwarded that prompts this question.
I want to get the date of the attachment inside the email. If anyone has done this, and has a full working code snippet to share, it would be greatly appreciated.
I have done several searches, looked carefully through email headers, looked at the two library documentation I am using (IMAPClient, and email), and see nothing that stands out that would lead to a solution.
Some file formats include this, most don't, some may. For example the EXIF data in some JPEG files includes it. To read that you'll need an EXIF library, not an IMAP library. Microsoft Word files include a creation date, IIRC that's mandatory for that format, but again you'll need a type-specific library.
IMAP is merely the channel through which you download the data you want to examine.

Python Email Validation

I have an old list of email addresses. I want to write a Python script to check which emails are still active and to which email can be sent. I tried using the validate_email package but it doesn't seem to work (e.g. when I input my own email address it says it's not deliverable). Any thoughts on how to do this in Python? Thanks.

How To Create a draft email?

I want to write a python that can sends data to a draft message, but NOT Send the mail directly.
Situation:
I'm a 3D animator. After done some shots, we need to send email(not internet, just in our company) to Lighting Team.
So we have some mail form, but sometimes we need to fix some words manual(version,texture..etc).
like below:
Shot Name : XXXX_seqXXX_scXXX
File Locate(hair + cloth) : please import X:\XX\XX\XX\XXX_ABC.ma
File include:
XXX_hair **(use version 1)**
XXX_cloth
ZZZ_cloth **(No texture)**
any problem please tell me.
Thanks.
Ezylryb
Question is:
Now I can write into a file, but I don't know how to open mail software(win7 Livemail) and create a new mail has these content. I'm try to use smtplib, but it will send mail directly..
Could anyone help me??
Many Thanks!!!!
Ezylryb
==============================
Finally, I write HTML code into a .html file, and a eml file with email address + Title + CC, and use os.startfile to open both files.
And I can copy/paste to draft email ^O^.
Coz we need some chinese words, so use big5 code in eml, and use qupori module to decode MIME words to Chinese words in html file.
A "draft" is a feature which your email client (in this case Win7 livemail) implements by itself. It's more or less just an email in a mailbox that the client hasn't sent yet. Mail folders like your "outbox" etc. are similar.
It's not something that Python has access to. If the mail client uses a standard mailbox format, you might be able to create the email and write it into the mailbox using mailbox module. If not, the best you can do is to write out your draft email into a file and then open that in your mail client and manually edit it.

Parsing All Mail from Mailbox File in Python

Maybe I'm going about this the wrong way, but I want to parse a single "catch all" email inbox via Python. I see the email module and I can make it parse an individual email, but what I want to do is open (for example) /var/spool/mail/catchall and parse all of the individual messages inside it. Opening that file and running the parser over it treats the whole thing as one giant email. How would I break it into individual messages?
Alternatively: is this A Bad Idea, given I'm going to want to delete the messages when I'm done with them? I'm tying this route instead of POP/ IMAP only because the server support isn't available right now.
You'll want to use mailbox to actually go through the mailbox.

Categories

Resources