Hello,
the simplest way to launch the user's standard mail client from a
Python program is by creating a mailto: URL and launching the
webbrowser:
def mailto_url(to=N one,subject=Non e,body=None,cc= None):
"""
encodes the content as a mailto link as described on http://www.faqs.org/rfcs/rfc2368.html
Examples partly taken from http://selfhtml.teamone.de/html/verweise/email.htm
"""
url = "mailto:" + urllib.quote(to .strip(),"@,")
sep = "?"
if cc:
url+= sep + "cc=" + urllib.quote(cc ,"@,")
sep = "&"
if subject:
url+= sep + "subject=" + urllib.quote(su bject,"")
sep = "&"
if body:
# Also note that line breaks in the body of a message MUST be
# encoded with "%0D%0A". (RFC 2368)
body="\r\n".joi n(body.splitlin es())
url+= sep + "body=" + urllib.quote(bo dy,"")
sep = "&"
return url
import webbrowser
url = mailto_url(...)
webbrowser.open (url,new=1)
(Excerpt from http://svn.berlios.de/wsvn/lino/trun...ile&rev=0&sc=0)
But this method is limited: you cannot specify a file to be attached
to the mail. And I guess that there would be problems if the body text
is too complex.
Does somebody know about a better method?
It should be possible at least on Windows, since Acrobat Reader is
able to do it.
Thanks in advance for any hints!
Luc Saffre
May 4 '07
14 4851
On 4 Mai, 18:54, cla...@lairds.u s (Cameron Laird) wrote:
.
Portland <URL:http://ct.enews.eweek. com/rd/cts?d=186-6281-53-799-798304-697089-0-0-0-1>
is the best standardization of this problem we have under Linux.
I'll address Windows in a subsequent follow-up.
Portland [1] provides scripts (xdg-open, xdg-email...) which overlap
with the functionality provided by the desktop module: http://www.python.org/pypi/desktop
The desktop module should even work with Windows as well, but it seems
that xdg-email has the edge in terms of providing the inquirer's
desired support for composing e-mail messages (on Free Software
desktops, anyway).
Paul
[1] http://portland.freedesktop.org/wiki/
In article <u2************ @lairds.us>, Cameron Laird <cl****@lairds. uswrote:
>In article <11************ **********@y80g 2000hsf.googleg roups.com>, lu********@gma il.com <lu********@gma il.comwrote:
>>Hello,
the simplest way to launch the user's standard mail client from a Python program is by creating a mailto: URL and launching the webbrowser:
def mailto_url(to=N one,subject=Non e,body=None,cc= None): """ encodes the content as a mailto link as described on http://www.faqs.org/rfcs/rfc2368.html Examples partly taken from http://selfhtml.teamone.de/html/verweise/email.htm """ url = "mailto:" + urllib.quote(to .strip(),"@,") sep = "?" if cc: url+= sep + "cc=" + urllib.quote(cc ,"@,") sep = "&" if subject: url+= sep + "subject=" + urllib.quote(su bject,"") sep = "&" if body: # Also note that line breaks in the body of a message MUST be # encoded with "%0D%0A". (RFC 2368) body="\r\n".joi n(body.splitlin es()) url+= sep + "body=" + urllib.quote(bo dy,"") sep = "&" return url
import webbrowser url = mailto_url(...) webbrowser.op en(url,new=1)
(Excerpt from http://svn.berlios.de/wsvn/lino/trun...ile&rev=0&sc=0)
But this method is limited: you cannot specify a file to be attached to the mail. And I guess that there would be problems if the body text is too complex.
Does somebody know about a better method? It should be possible at least on Windows, since Acrobat Reader is able to do it.
. . . Portland <URL: http://ct.enews.eweek.com/rd/cts?d=1...697089-0-0-0-1 > is the best standardization of this problem we have under Linux.
I'll address Windows in a subsequent follow-up.
A. Apologies! I'm sorry about the URL above; it was
completely wrong. I intended <URL: http://www-128.ibm.com/developerwork...-portland.html >.
B. The best approach I know under Windows is to invoke
start mailto:$ADDRESS
1. That invocation does *not* communicate
subject, attachments, ... To do so
adequately involves application-specific
work, as other follow-ups have mentioned.
2. "start" has its own complexities. The
best invocation from console-based Python
is likely to be
start /w "" mailto:$ADDRESS
On May 7, 10:28 am, "Gabriel Genellina" <gagsl-...@yahoo.com.a r>
wrote:
>
Get the pywin32 package (Python for Windows extensions) from sourceforge,
install it, and look into the win32comext\map i\demos directory.
Thanks for the hint, Gabriel.
Wow, that's heavily spiced code! When I invoke mapisend.py I get:
Traceback (most recent call last):
File "mapisend1. py", line 85, in <module>
SendEMAPIMail(S endSubject, SendMessage, SendTo,
MAPIProfile=MAP IProfile)
File "mapisend1. py", line 23, in SendEMAPIMail
mapi.MAPIInitia lize(None)
pywintypes.com_ error: (-2147467259, 'Unspecified error', None, None)
But what is a MAPI profile? I left this variable blank. Do I need MS
Exchange Server to run this demo?
En Mon, 07 May 2007 18:00:06 -0300, lu********@gmai l.com
<lu********@gma il.comescribió:
On May 7, 10:28 am, "Gabriel Genellina" <gagsl-...@yahoo.com.a r>
wrote:
>> Get the pywin32 package (Python for Windows extensions) from sourceforge, install it, and look into the win32comext\map i\demos directory.
Thanks for the hint, Gabriel.
Wow, that's heavily spiced code! When I invoke mapisend.py I get:
Traceback (most recent call last):
File "mapisend1. py", line 85, in <module>
SendEMAPIMail(S endSubject, SendMessage, SendTo,
MAPIProfile=MAP IProfile)
File "mapisend1. py", line 23, in SendEMAPIMail
mapi.MAPIInitia lize(None)
pywintypes.com_ error: (-2147467259, 'Unspecified error', None, None)
But what is a MAPI profile? I left this variable blank.
You can register several profiles (or users, or accounts); leave it blank
to use the default profile.
Do I need MS
Exchange Server to run this demo?
No. But this simple example used to work fine for me, but not anymore :( .
Perhaps it has to do with my Eudora configuration. I've never used Outlook
nor OutlookExpress btw.
You may find this thread interesting: http://mail.python.org/pipermail/pyt...er/003985.html
--
Gabriel Genellina
On May 7, 2:00 pm, "luc.saf...@gma il.com" <luc.saf...@gma il.com>
wrote:
On May 7, 10:28 am, "Gabriel Genellina" <gagsl-...@yahoo.com.a r>
wrote:
Get the pywin32 package (Python for Windows extensions) from sourceforge,
install it, and look into the win32comext\map i\demos directory.
Thanks for the hint, Gabriel.
Wow, that's heavily spiced code! When I invoke mapisend.py I get:
Traceback (most recent call last):
File "mapisend1. py", line 85, in <module>
SendEMAPIMail(S endSubject, SendMessage, SendTo,
MAPIProfile=MAP IProfile)
File "mapisend1. py", line 23, in SendEMAPIMail
mapi.MAPIInitia lize(None)
pywintypes.com_ error: (-2147467259, 'Unspecified error', None, None)
But what is a MAPI profile?
It's an abstraction of incoming and outgoing mail accounts. In UNIX
terms it's kind of like running local sendmail that forwards mail to
another server and fetchmail that fetches mail from external inboxes,
e.g. it's a proxy between you and outgoing/incoming mail server.
I left this variable blank. Do I need MS
Exchange Server to run this demo?
No, but you need an account on some mail server and some email program
should create a MAPI profile to represent that account on your local
computer. As I understand creation of MAPI profiles is not a common
practice among non-Microsoft products, for example my computer with
Lotus Notes doesn't have any MAPI profiles.
-- Leo This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: John Altland |
last post by:
Here is my basic problem. I have a form that executes a
cpu instensive algorithm occupying the first thread. When
the algorithm is executed another form pops up telling the
user the progress that has been made.
Whenever I attempt to update my frmProgress, the events
are put placed at the end of the thread's queue and
executed after my algorithm is finished. Using the
frmProgress.Label.Invoke method with delagates, I have
heard would fix...
|
by: Peter Amberg |
last post by:
I would like to create a link on my page that opens the standard
e-mail application when someone clicks it. It should have at least the
subject preset, better if I could preset the body as well. I read
somewhere that the TITLE attribute of the A HREF tag can be used to
set a subject, so I tried:
<A HREF="mailto:" TITLE="MySubject">
This would open the e-mail application, but the TITLE attribute is
completely ignored, at least on...
|
by: Mike |
last post by:
Is there a way to determine what a user's default email client is? I
read a post from 3 years ago that said no. I guess I'm hoping
something has come along since then.
|
by: news.btinternnet.com |
last post by:
I can do this in IE
myLink.click(); //Invoking the handler as if the user had clicked on the
link themselves.
I need to be able to do the same in Netscape Navigator,
can anyone help ?
|
by: stic |
last post by:
Hi,
I'm in a middle of writing something like 'exception handler wraper'
for a set of different methodes.
The case is that I have ca. 40 methods form web servicem, with
different return values (and types), and with out parmeters. What I
want to do is to support each method call with exception (http 404,
soap exception, and other types of exceptions) and wrap it with try &
catch (a lots of catch ;-)
| |
by: John Lafrowda |
last post by:
Hello experts,
I'm coding a routine which should open a new mail form of the mail standard
mail client installed on a system (e.g. outlook, outlook express, netscape
mail, etc.) for support reasons. The routine should fill in some textual
information. It should, however, not mail the information directly. The user
should be able to check the contents of the mail and he should be able to
edit the mail before sending it.
Consequently, I...
|
by: Wayne Wengert |
last post by:
I have a Windows application in which users can select one or more
individuals and an email message is created which they then complete and
send. I currently use MAPI for this but I want to change the code to invoke
whatever email client the users has as the default. Any pointers to some
information on how to do this would be appreciated.
Wayne
|
by: stephan querengaesser |
last post by:
hi ng,
i try to invoke a webservice-method with an filter-object, that
contains value types. if i don´t want to filter the return value of
the method, i have to pass a new instance of the filter-object without
setting any properties. but the value type-properties can´t be null
and the filter is set to 0 (int) or false (bool).
therefore i did implement the propertySpecified-pattern like this:
|
by: Ricardo Vazquez |
last post by:
Hi!
I have a new problem with this SCENARIO I already described in a previous
post:
- PBX (a private telephone exchange or switch)
- A Telephony Server Application running on computer "A" (it communicates
with the PBX via IP)
- An ASP.NET application (running on computer "A") for web clients of that
telephony server (running on computer "B", "C", etc.)
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |