Python - automate emails in existing email threads - python

I have 20 providers.
I need to ask quotes from each provider every week, based on a quote list I have.
Each providers has its own email thread with a specific email title (I don't want to send a new email to each provider every).
Is there a way to automate this with Python?
I see a lot of material to create new emails, but not to automate emails based on existing email threads.
Thank you!
I haven't tried anything yet as I'm very new to Python

Related

How to login of my skype business account using python?

I want to write a python code that will sign in to skype business 2016 account.After doing few research, UCWA is the only way to do so.i am attaching the my account image below. As you can see , there is no password field.
So how to login using python??Any link would be helpful.
skype image
p.s - i am using my business account id to sign-in and i guess we only use id to sign in. (never saw any password field even in outlook or onedrive )
Skype for Business is a completely different product from Skype, and uses a different protocol.
SkPy is a client for Skype, not Skype for Business. You will need to use a different library to interact with Skype for Business -- one option appears to be ucwa.

Information Extraction from Text into Structured Data with Python

I'm near a total outsider of programming, just interested in it.
I work in a Shipbrokering company and need to match between positions (which ship will be open at where, when) and orders (what kind of ships will be needed at where, when for what kind of employment).
And we send and receive such info (positions and orders) by emails to and from our principals and co-brokers.
There are thousands of such emails each day.
We do the matching by reading the emails manually.
I want to build an app to do the matching for us.
One important part of this app will do the information extraction from email text.
==> My question is how do I use Python to extract unstructured info into structured data.
Sample email of an order [annotation in the brackets, but is not included in the email]:
Email Subject: 20k dwt requirement, 20-30/mar, Santos-Conti
Content:
Acct ABC [Account Name]
Abt 20,000 MT Deadweight [Size of Ship Needed]
Delivery to make Santos [Delivery Point/Range, Owners will deliver the ship to Charterers here]
Laycan 20-30/Mar [Laycan (the time spread in which delivery can be accepted]
1 time charter with grains [What kind of Empolyment/Trade, Cargo]
Duration about 35 days [Duration]
Redelivery 1 safe port Continent [Redelivery Point/Range, Charterers will redeliver the ship back to Owners here.]
Broker name/email/phone...
End Email
Same email above can be written in many different ways - some writes in one line, some use l/c instead of laycan...
And there are emails for positions with ship's name, open port, date range, ship's deadweight and other specs.
How can I extract the info and put it into structured data, with Python?
Let's say I have put all email contents into text files.
Thanks.
Below is a possible approach:
Step 1: Classify the mails in categories using the subject and/or message in the mail.
As you stated one category is of mails requesting position and the other is of mails of order.
Machine Learning can be used to classify. You can use set of previous mails as training corpus. You might consider using NLTK(Natural Langauage Toolkit) for Python. Here is the link on text classification using NLTK.
Step 2: Once an email is identified as an order mail, process it to fetch the details(account name, size, time spread etc.) As you mentioned the challenge here is that there is no fixed format for these data. To solve this problem, you might consider preparing an exhaustive list of synonyms for each label(like for account the list could be like ['acct', 'a/c', 'account', 'acnt']). This should be done once, by going through a fixed volume of previous mails.
To make the solution more effective, you could consider implementing option for active learning
(i.e., prompt the user if in a mail a lable is found which is not found in any list. E.g. in a mail, if "accnt" is used, it wont be resolved, hence user should be prompted to ask in which category it falls.)
Once a lable is identifies, you can use basic string operations, to parse the email in a fetch relevant data in structured format.
You can refer to this discussion for a better understanding.

Adding to Google Group based on Google Spreadsheet data validation

So I'd like to preface this with the fact that I am NOT a programmer. I know a little Python, but that's about it.
So this is what I'm trying to do:
User fills out a Google Form and the responses are dumped into a spreadsheet. As a part of the form, their email address is captured in "'Form Responses'B:B"
Not sure if this is even possible, but I'd like to know:
for row X If column P = yes and column c = Accept and column F = Yes
Capture email from Column B and add them to GoogleGroup and send Welcome_Email
Please help! :)
Thanks in advance.
Google Apps Script is JavaScript.
When you build the form in Google Forms, set the Data Validation for the email field to require email address. That way you don't have to hassle with validating it yourself.
http://googledrive.blogspot.com/2013/09/four-new-ways-to-customize-your-google.html
Once the form is built, go to Tools, Script Editor, and make a new Blank Project.
Replace any code in there with this:
function addToGroup(e){
var itemResponses = e.response.getItemResponses();
var emailAddress = itemResponses[#].getResponse();
var group = GroupsManager.getGroup("group name").addMember(emailAddress);
GmailApp.sendEmail(emailaddress, "Welcome to Group Name!", "You have been successfully added to Group Name");
}
https://developers.google.com/apps-script/reference/gmail/gmail-app#sendEmail(String,String,String)
Replace # with the zero-indexed number of the column containing the email addresses, and group name is the mailbox name of the group on your Google Apps domain.
Then you just need to send the welcome email.
Save the project, and go to Resources> Current Script's Triggers. Set it run the addToGroup script on FormSubmit, Authorize it when prompted, and that should be it for you.
https://developers.google.com/apps-script/reference/domain/groups-manager
http://support.google.com/a/bin/answer.py?hl=en&answer=60757
This only works with Google Apps accounts, and only if you have the Provisioning API turned on in your domain admin console. If you're using a standard consumer Google account, they don't have anything available to do this.
Doing a few searches on this forum on words like email or groups you'll find quite a few scripts and if you spend a couple of hours looking at how they are built you'll be able to write something that does what you want...
If at that moment you meet some unexpected difficulties you'll be welcome to ask for help if you show what you've done.

An Email Report Application for Outlook

The sales folk in my start-up send and receive a bunch of mail on a daily basis from vendors. dealers and customers.
But they tend to lose track of these mails quite often...as to whether they have responded/followed-up or not. And they waste a lot of time on figuring this out.
Expecting them to use a Mail Tool like MailChimp is even more painful and a ticketing tool is not a good fit for the jobs.
Hence, I am trying to build an app that can create a report of the total Email IDs interacted with in a particular date range. The only goal is to create a report, in a csv file or to dump the data into Google spreadsheets.
The report for the period entered by the user would look as below:
Email ID - All emails lying in "sent items" AND "inbox" for particular date range
Name - If present
Status
The "Status" would be:
Received not responded by sales person
Sent but not responded by recipient
Responded by Sales Person
...and so on
I am vary of running the script directly on the mail server and am not sure if Outlook Exchange would allow something like this.
I would prefer if it could be an application that runs directly on the sales person's machine.
A few use Macs and the others Windows. I would be focussing on the Macs first.
The mail tool used is Outlook for Mac-2011 and the machines are either Lions or Snow Leopards.
Mail is on the Outlook Exchange
I must confess to be not much of a coder, but i blunder/Google my was through it.
I had some time on my hand with the holiday season coming up, hence thought of taking this project up.
I am moderately comfortable with Python.
But for this project, from what i have read, appears to be the job for AppleScripting.
Before starting my blunderings, i wanted to seek the advice of the SO community on the same:
Is AppleScripting the best bet here? If yes, could you share the best resource to read up the same. I have the copy of "AppleScript The Comprehensive Guide to Scripting and Automation on Mac OS X". But it is almsot 6 years old.
Could it be done somehow just using Python? - I wanted to dump the respective reports onto Google Spreadsheets, hence would be easier to get Python involved here.
Are there any similar applications that are already out there?
Or am i completely off track
Sorry for the ramble. But really Looking forward to some assistance on this
I liked:
AppleScript 1-2-3
and
AppleScript: The Definitive Guide
There also some good tutorials here: MacScripter
That being said, you should consider the cost/benefit of learning AppleScript to accomplish one task at your company. You may be better off simply hiring someone to write the script for you and focus on growing your business instead.

Email title and link from rss-feed and email them

I'm doing a bit of an experiment in Python. I'm making a script which checks a rss-feed for new items, and then sends the title and link of the items via email. I've got the script to work to a certain level: when it runs it will take the link+title of the newest item and email it, regardless of wether it emailed that file already or not. I'd need to add 2 things: a way to get multiple items at once (and email those, one by one), and a way to check wether they have been sent already. How would I do this? I'm using feedparser, this is what I've got so far:
d = feedparser.parse('http://feedparser.org/docs/examples/rss20.xml')
link = d.entries[0].link
title = d.entries[0].title
And then a couple of lines which send an email with "link" and "title" in there. I know I'd need to use the Etag, but haven't been able to work out how, and how would I send the emails 1 by 1?
for the feed parsing part, you could consider following the advise given in this question regarding How to detect changed and new items in an RSS feed?. Basically, you could hash the contents of each entry and use that as an id.
For instance, on the first run of your program it will calculate the hash of each entry, store that hash, and send these new entries by mail. On it's next run, it will rehash each entry's content and compare those hashes with the ones found before (you should use some sort of database for this, or at least an on memory dictionary/list when developing with the entries already parsed and sent). If your program finds hashes that where not generated on the previous runs, it will assemble a new email and send it with the "new" entries.
As for your email assembling part, the question Sending HTML email in Python could help. Just make sure to send a text only and a html version.
For the simplest method see the python smtplib documentation example. (I won't repeat the code here.) It's all you need for basic email sending.
For nicer/more complicated email content also look into python's email module, of course.

Categories