Skip to content

Commit

Permalink
Merge pull request #48 from Davideddu/windows_email
Browse files Browse the repository at this point in the history
add Windows email support
  • Loading branch information
tito committed Jun 24, 2014
2 parents 861e756 + 339002a commit fcbbe05
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions plyer/platforms/win/email.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import os
from urllib import quote
from plyer.facades import Email

class WindowsEmail(Email):
def _send(self, **kwargs):
recipient = kwargs.get('recipient')
subject = kwargs.get('subject')
text = kwargs.get('text')
create_chooser = kwargs.get('create_chooser')

uri = "mailto:"
if recipient:
uri += str(recipient)
if subject:
uri += "?" if not "?" in uri else "&"
uri += "subject="
uri += quote(str(subject))
if text:
uri += "?" if not "?" in uri else "&"
uri += "body="
uri += quote(str(text))

try:
os.startfile(uri)
except WindowsError:
print "Warning: unable to find a program able to send emails."


def instance():
return WindowsEmail()

0 comments on commit fcbbe05

Please sign in to comment.