| 1 |
''' |
| 2 |
Module of Windows API for plyer.email. |
| 3 |
''' |
| 4 |
|
| 5 |
import os |
| 6 |
try: |
| 7 |
from urllib.parse import quote |
| 8 |
except ImportError: |
| 9 |
from urllib import quote |
| 10 |
from plyer.facades import Email |
| 11 |
|
| 12 |
|
| 13 |
class WindowsEmail(Email): |
| 14 |
''' |
| 15 |
Implementation of Windows email API. |
| 16 |
''' |
| 17 |
|
| 18 |
def _send(self, **kwargs): |
| 19 |
recipient = kwargs.get('recipient') |
| 20 |
subject = kwargs.get('subject') |
| 21 |
text = kwargs.get('text') |
| 22 |
|
| 23 |
uri = "mailto:" |
| 24 |
if recipient: |
| 25 |
uri += str(recipient) |
| 26 |
if subject: |
| 27 |
uri += "?" if "?" not in uri else "&" |
| 28 |
uri += "subject=" |
| 29 |
uri += quote(str(subject)) |
| 30 |
if text: |
| 31 |
uri += "?" if "?" not in uri else "&" |
| 32 |
uri += "body=" |
| 33 |
uri += quote(str(text)) |
| 34 |
|
| 35 |
|
| 36 |
try: |
| 37 |
os.startfile(uri) |
| 38 |
except WindowsError: |
| 39 |
print("Warning: unable to find a program able to send emails.") |
| 40 |
|
| 41 |
|
| 42 |
def instance(): |
| 43 |
''' |
| 44 |
Instance for facade proxy. |
| 45 |
''' |
| 46 |
return WindowsEmail() |