outlook.py 789 B

123456789101112131415161718192021222324252627282930
  1. '''
  2. Interface avec MS Outlook (via win32)
  3. @author: olivier.massot, sept. 2017
  4. '''
  5. import win32com.client as win32
  6. def display_mail(to, subject, content, attachments=[]):
  7. """ Créé et affiche le mail de réponse prêt à l'envoi """
  8. outlook = win32.Dispatch('outlook.application')
  9. mail = outlook.CreateItem(0)
  10. mail.To = to
  11. mail.Subject = subject
  12. mail.HtmlBody = content
  13. for path in attachments:
  14. mail.Attachments.Add(path)
  15. mail.Display(True)
  16. class Mail():
  17. def __init__(self, to, subject, content, attachments=[]):
  18. self.to = to
  19. self.subject = subject
  20. self.content = content
  21. self.attachments = attachments
  22. def display(self):
  23. display_mail(self.to, self.subject, self.content, self.attachments)