Ian,
thanks for posting simplemapi.py. I can report that it works. I use Thunderbird as mail client. Thunderbird notifies me as follows about the MAPI request:
Another application is attempting to send mail using your user profile. Are you sure you wxant to send mail?
[x] Warn me whenever other applications try to send mail from me.
TB does not let me edit the file before sending it (a feature that could be nice). Anyway I didn't yet find documentation about how to configure TB's behaviour with MAPI...
Until now I solved the same problem with a different approach::
# source: # http://lsaffre.dyndns.org/websvn/filedetails.php?repname=lino\ # &path=%2Ftrunk%2Fsrc%2Flino%2Ftimtools%2Fmail.py&rev=0&sc=0
import urllib import webbrowser
def mailto_url(to=None,subject=None,body=None,cc=None): """ encodes the content as a mailto link as described on http://www.faqs.org/rfcs/rfc2368.html """ url = "mailto:" + urllib.quote(to.strip(),"@,") sep = "?" if cc: url+= sep + "cc=" + urllib.quote(cc,"@,") sep = "&" if subject: url+= sep + "subject=" + urllib.quote(subject,"") 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".join(body.splitlines()) url+= sep + "body=" + urllib.quote(body,"") sep = "&" return url
def openmail(msg): url = mailto_url(msg.get('to'),msg.get("subject"),msg.get_payload()) webbrowser.open(url,new=1)
I added your module to my own project "Lino" which I publish under the GPL. Here is a link to the SVN repository:
http://lsaffre.dyndns.org/websvn/filedetails.php?repname=lino&path=%2Ftrunk%2Fsrc%2Fforum%2Fsimplemapi.py&rev=0&sc=0
Please let me know if you have a copyright problem with this.
Luc Saffre
On 28.12.2004 03:12, Ian Cook wrote:
Hi Everyone,
Recently I found out how to send emails using Python via the default email client (eg Outlook Express)
A suggestion was made to post a message here.
The script will allow multiple recipients and multiple attachements.
*Syntax*
simplemapi.SendMail(recipient,subject,body,attachment)
where:
recipient - string: address to send to (multiple address sperated with a semicolin)
subject - string: subject header
body - string: message text
attach - string: files to attach (multiple attachments sperated with a semicolin)
*Example usage*
import simplemapi
simplemapi.SendMail("[EMAIL PROTECTED];[EMAIL PROTECTED]","My Subject","My message body","c:\attachment1.txt;c:\attachment2")
I hope it is of some help to others.
You can download the script from http://www.kirbyfooty.com/simplemapi.py <http://www.kirbyfooty.com/simplemapi.py>
Kind regards
Ian Cook
www.kirbyfooty.com <http://www.kirbyfooty.com>
------------------------------------------------------------------------
_______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
_______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32