-
Notifications
You must be signed in to change notification settings - Fork 431
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from Davideddu/windows_email
add Windows email support
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |