• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Write a Python script that automatically prints emails in inbox?

Status
Not open for further replies.
Level 15
Joined
Aug 7, 2013
Messages
1,338
Hi,

How would I write a script in Python that does the following:

1. Whenever a printer device is connected to my computer

2. Browse the inbox of my email and for every message that contains some keyword / is from a particular person: print that message


Or at least how would I write a script that just does 2 (I would manually call it I suppose?).
 
Level 15
Joined
Aug 7, 2013
Messages
1,338
Thanks GhostWolf.

I ended up using imap and your links were helpful, though not sufficient :p.

So there's is a lot of support for accessing gmail in both Python and Java.

The hardest part was figuring out how to print everything-getting emails is easy once familiar with the API. I wasn't able to install pycups because I guess it has to do with how I installed Windows 7 (bootcamp) and I've been using the Windows side of my machine because my hdmi display doesn't support retina.

To print each document I wrote a script that literally opens the file (i.e. double clicking it) and then I use the win32api to literally do the key board event "ctrl + p" followed by "enter." It's rather silly, but it does work.

Apparently there is very little support in Python or Java for actually printing stuff to a printer. I know this about Java because no one was able to help me a year ago when I needed to use the printer in Java, and my school did mostly Java.

Also, windows command prompt is terrible at printing stuff too.

In any case, now when I need to print attachments I just run a quick script rather than comb through my gmail. ^^
 
Status
Not open for further replies.
Top