2016-07-20 1 views
2

Je dois envoyer un email en python si mon travail échoue, mais en raison des politiques de l'entreprise, je suis seulement autorisé à utiliser Outlook Web Access. Comment puis-je me connecter à Outlook Web Access à partir de python pour envoyer un e-mail?Comment envoyer un e-mail à partir de python en utilisant Outlook Web Access?

+0

vérifier ces liens: [http://stackoverflow.com/questions/6332577/send-outlook-email-via-python] (http://stackoverflow.com/ questions/6332577/send-outlook-email-via-python) [http://www.holovaty.com/writing/python-outlook-web-access/](http://www.holovaty.com/writing/python -outlook-web-access /) – Vaibhav

Répondre

1

Je ne peux pas prendre le crédit pour cela mais je peux vous conduire à une solution possible.

Voici le lien: http://win32com.goermezer.de/content/view/227/192/ Voici le code

import win32com.client 

s = win32com.client.Dispatch("Mapi.Session") 
o = win32com.client.Dispatch("Outlook.Application") 
s.Logon("Outlook2003") 

Msg = o.CreateItem(0) 
Msg.To = "[email protected]" 

Msg.CC = "more email addresses here" 
Msg.BCC = "more email addresses here" 

Msg.Subject = "The subject of you mail" 
Msg.Body = "The main body text of you mail" 

attachment1 = "Path to attachment no. 1" 
attachment2 = "Path to attachment no. 2" 
Msg.Attachments.Add(attachment1) 
Msg.Attachments.Add(attachment2) 

Msg.Send() 

C'est cool et je dois l'utiliser. Une question SO connexe peut être trouvée ici: Python - Send HTML-formatted email via Outlook 2007/2010 and win32com

+0

Je devrais aussi mentionner que j'essaye d'envoyer des emails de mac/linux – mmmtoasted

+0

Ah, je vois. C'est une mise en garde importante. Je vais creuser un peu. –