Re: html page mail link to webmail program

2014-12-02 Thread Cameron Simpson

On 11Nov2014 17:35, Ethan Furman  wrote:

Okay, the explicit Python question:  Clicking on a mail link in a web browser 
can start an external program.  I would like that external program to be a 
Python script that: opens a new tab in the currently running browser (or a new 
default browser window), loads up the default web mail client (or one specified 
if there is no way to know/have a default), navigates to the compose pane (or 
starts there if possible), enters in the email address from the link that was 
passed to it, and, if not too much more, move the cursor to the subject field.

Surely this can be done in Python.


Yes and no. It is dependent on how much control GMail allows you from outside.

A quick web search on "open gmail compose using url" led me to this discussion:

 http://stackoverflow.com/a/8852679

which espouses this URL template:

 
https://mail.google.com/mail/?view=cm&fs=1&to=some...@example.com&su=SUBJECT&body=BODY&bcc=someone.e...@example.com

which I have tested, and it works. It does require your browser to be logged 
into GMail already.


Given that, you just need a Python script that can be invoked as a standard 
browser external mail client accepting the mailto: URL from the browser. Decode 
the URL into to/subject/etc and then open the right URL using the above 
template.


As an exercise, I wrote a short shell script:

 https://bitbucket.org/cameron_simpson/css/src/tip/bin-cs/gmail

which I would invoke from a shell prompt as:

 gmail -s "subject line here" j...@blogs.com b...@ben.com ...

Adapting it to (a) Python (b) accept a mailto:URL and decoding its fields and 
(c) opening that URL from inside Python using the "webbrowser" module's:


 https://docs.python.org/3/library/webbrowser.html#module-webbrowser

"open" function I leave as an exercise for the reader. Should take less thatn 
an hour I'd hope.


Cheers,
Cameron Simpson 

Perhaps this morning there were only three Euclidean solids, but god changed
its mind retroactively at lunchtime, remaking the whole history of the
universe.  That's the way it is with omnipotent beings.
   - mi...@apple.com (Mikel Evins)
--
https://mail.python.org/mailman/listinfo/python-list


Re: html page mail link to webmail program

2014-11-27 Thread Akira Li
Ethan Furman  writes:

> On 11/11/2014 05:08 PM, Ben Finney wrote:
>> Ethan Furman  writes:
>>
>>> My wife (using a Win7 machine) will be on a web page that has a link
>>> to mail somebody.  She clicks on it, and it opens the currently
>>> installed but unused Thunderbird.
>>>
>>> Ideally, what would happen is a new window/tab would open to gmail
>>> with a new compose window with the email address in place and the
>>> cursor in the subject line.
>>
>> What is the Python question? I can't see anywhere that you would be
>> using Python code to address this.
>
> Really?  Huh.
>
> Okay, the explicit Python question:  Clicking on a mail link in a web
> browser can start an external program.  I would like that external
> program to be a Python script that: opens a new tab in the currently
> running browser (or a new default browser window), loads up the
> default web mail client (or one specified if there is no way to
> know/have a default), navigates to the compose pane (or starts there
> if possible), enters in the email address from the link that was
> passed to it, and, if not too much more, move the cursor to the
> subject field.
>
> Surely this can be done in Python.
>
Related question:
http://stackoverflow.com/questions/14288177/interact-with-other-programs-using-python


--
Akira

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: html page mail link to webmail program

2014-11-12 Thread Jerry Hill
On Tue, Nov 11, 2014 at 8:04 PM, Ethan Furman  wrote:
> My wife (using a Win7 machine) will be on a web page that has a link to mail
> somebody.  She clicks on it, and it opens the currently installed but unused
> Thunderbird.

As others have mentioned, this is more a question of configuring your
browser than anything involving python.

That said, those links on a web page that open an email window are
called "mailto" links.  A google search for "open mailto links in
gmail" (without the quotes) gets a bunch of general information, and
if you add your wife's browser of choice to the search terms, you
should get some explicit instructions for setting everything up
properly.

-- 
Jerry
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: html page mail link to webmail program

2014-11-12 Thread Joel Goldstick
On Wed, Nov 12, 2014 at 3:58 AM, alister
 wrote:
> On Wed, 12 Nov 2014 08:56:07 +, alister wrote:
>
>> On Tue, 11 Nov 2014 17:35:11 -0800, Ethan Furman wrote:
>>
>>> On 11/11/2014 05:08 PM, Ben Finney wrote:
 Ethan Furman  writes:

> My wife (using a Win7 machine) will be on a web page that has a link
> to mail somebody.  She clicks on it, and it opens the currently
> installed but unused Thunderbird.
>
> Ideally, what would happen is a new window/tab would open to gmail
> with a new compose window with the email address in place and the
> cursor in the subject line.

There are plugins on chrome to make gmail the mail client.  Firefox I
think has a setting to do the same.  You should look into the
browser/OS settings before rolling your own, since using python means
setting up a web site.. all this to pick the default mail client?

 What is the Python question? I can't see anywhere that you would be
 using Python code to address this.
>>>
>>> Really?  Huh.
>>>
>>> Okay, the explicit Python question:  Clicking on a mail link in a web
>>> browser can start an external program.  I would like that external
>>> program to be a Python script that: opens a new tab in the currently
>>> running browser (or a new default browser window), loads up the default
>>> web mail client (or one specified if there is no way to know/have a
>>> default), navigates to the compose pane (or starts there if possible),
>>> enters in the email address from the link that was passed to it, and,
>>> if not too much more, move the cursor to the subject field.
>>>
>>> Surely this can be done in Python.
>>
>> any chance you could fix your broken news reader?
>
> Apologies, all posts seem broken today. I am not sure of the cause yet
>
>
>
> --
> Boren's Laws:
> (1) When in charge, ponder.
> (2) When in trouble, delegate.
> (3) When in doubt, mumble.
> --
> https://mail.python.org/mailman/listinfo/python-list



-- 
Joel Goldstick
http://joelgoldstick.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: html page mail link to webmail program

2014-11-12 Thread alister
On Wed, 12 Nov 2014 08:56:07 +, alister wrote:

> On Tue, 11 Nov 2014 17:35:11 -0800, Ethan Furman wrote:
> 
>> On 11/11/2014 05:08 PM, Ben Finney wrote:
>>> Ethan Furman  writes:
>>>
 My wife (using a Win7 machine) will be on a web page that has a link
 to mail somebody.  She clicks on it, and it opens the currently
 installed but unused Thunderbird.

 Ideally, what would happen is a new window/tab would open to gmail
 with a new compose window with the email address in place and the
 cursor in the subject line.
>>>
>>> What is the Python question? I can't see anywhere that you would be
>>> using Python code to address this.
>> 
>> Really?  Huh.
>> 
>> Okay, the explicit Python question:  Clicking on a mail link in a web
>> browser can start an external program.  I would like that external
>> program to be a Python script that: opens a new tab in the currently
>> running browser (or a new default browser window), loads up the default
>> web mail client (or one specified if there is no way to know/have a
>> default), navigates to the compose pane (or starts there if possible),
>> enters in the email address from the link that was passed to it, and,
>> if not too much more, move the cursor to the subject field.
>> 
>> Surely this can be done in Python.
> 
> any chance you could fix your broken news reader?

Apologies, all posts seem broken today. I am not sure of the cause yet



-- 
Boren's Laws:
(1) When in charge, ponder.
(2) When in trouble, delegate.
(3) When in doubt, mumble.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: html page mail link to webmail program

2014-11-12 Thread alister
On Tue, 11 Nov 2014 17:35:11 -0800, Ethan Furman wrote:

> On 11/11/2014 05:08 PM, Ben Finney wrote:
>> Ethan Furman  writes:
>>
>>> My wife (using a Win7 machine) will be on a web page that has a link
>>> to mail somebody.  She clicks on it, and it opens the currently
>>> installed but unused Thunderbird.
>>>
>>> Ideally, what would happen is a new window/tab would open to gmail
>>> with a new compose window with the email address in place and the
>>> cursor in the subject line.
>>
>> What is the Python question? I can't see anywhere that you would be
>> using Python code to address this.
> 
> Really?  Huh.
> 
> Okay, the explicit Python question:  Clicking on a mail link in a web
> browser can start an external program.  I would like that external
> program to be a Python script that: opens a new tab in the currently
> running browser (or a new default browser window), loads up the default
> web mail client (or one specified if there is no way to know/have a
> default), navigates to the compose pane (or starts there if possible),
> enters in the email address from the link that was passed to it, and, if
> not too much more, move the cursor to the subject field.
> 
> Surely this can be done in Python.

any chance you could fix your broken news reader?



-- 
Life is to you a dashing and bold adventure.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: html page mail link to webmail program

2014-11-11 Thread Chris Angelico
On Wed, Nov 12, 2014 at 12:42 PM, Ben Finney  wrote:
> Ethan Furman  writes:
>
>> Okay, the explicit Python question: Clicking on a mail link in a web
>> browser can start an external program. I would like that external
>> program to be a Python script that [controls an already-running web
>> browser to visit a URL and operate a web application].
>>
>> Surely this can be done in Python.
>
> Perhaps. I'd advise a web search for “python script web browser”, and be
> prepared for also learning how your specific operating system allows
> programs to control each other in separate processes.

Or just look at antigravity.py in the standard library, which has a
way of invoking a web browser - probably something trivially easy,
like calling on the webbrowser module, but it's more fun to look it up
via the arcane.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: html page mail link to webmail program

2014-11-11 Thread Ben Finney
Ethan Furman  writes:

> Okay, the explicit Python question: Clicking on a mail link in a web
> browser can start an external program. I would like that external
> program to be a Python script that [controls an already-running web
> browser to visit a URL and operate a web application].
>
> Surely this can be done in Python.

Perhaps. I'd advise a web search for “python script web browser”, and be
prepared for also learning how your specific operating system allows
programs to control each other in separate processes.

-- 
 \   “Either he's dead or my watch has stopped.” —Groucho Marx |
  `\   |
_o__)  |
Ben Finney

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: html page mail link to webmail program

2014-11-11 Thread Ethan Furman

On 11/11/2014 05:08 PM, Ben Finney wrote:

Ethan Furman  writes:


My wife (using a Win7 machine) will be on a web page that has a link
to mail somebody.  She clicks on it, and it opens the currently
installed but unused Thunderbird.

Ideally, what would happen is a new window/tab would open to gmail
with a new compose window with the email address in place and the
cursor in the subject line.


What is the Python question? I can't see anywhere that you would be
using Python code to address this.


Really?  Huh.

Okay, the explicit Python question:  Clicking on a mail link in a web browser can start an external program.  I would 
like that external program to be a Python script that: opens a new tab in the currently running browser (or a new 
default browser window), loads up the default web mail client (or one specified if there is no way to know/have a 
default), navigates to the compose pane (or starts there if possible), enters in the email address from the link that 
was passed to it, and, if not too much more, move the cursor to the subject field.


Surely this can be done in Python.

--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list


Re: html page mail link to webmail program

2014-11-11 Thread Ben Finney
Ethan Furman  writes:

> My wife (using a Win7 machine) will be on a web page that has a link
> to mail somebody.  She clicks on it, and it opens the currently
> installed but unused Thunderbird.
>
> Ideally, what would happen is a new window/tab would open to gmail
> with a new compose window with the email address in place and the
> cursor in the subject line.

What is the Python question? I can't see anywhere that you would be
using Python code to address this.

-- 
 \“Some people, when confronted with a problem, think ‘I know, |
  `\   I'll use regular expressions’. Now they have two problems.” |
_o__)   —Jamie Zawinski, in alt.religion.emacs |
Ben Finney

-- 
https://mail.python.org/mailman/listinfo/python-list


html page mail link to webmail program

2014-11-11 Thread Ethan Furman

Just in case that subject line is not perfectly clear:  ;)

My wife (using a Win7 machine) will be on a web page that has a link to mail somebody.  She clicks on it, and it opens 
the currently installed but unused Thunderbird.


Ideally, what would happen is a new window/tab would open to gmail with a new compose window with the email address in 
place and the cursor in the subject line.


Is this already done somewhere?  If not, any ideas on which libs/packages to 
use to make it happen?

--
~Ethan~
--
https://mail.python.org/mailman/listinfo/python-list