title: Copy Word contents into Outlook
body: <p>I have a Word document with formatted text, images, and tables. You can manually copy its contents and insert into Outlook with no problems. How to do it in Python?</p>
  
  <p><strong>My code:</strong></p>
  
  <pre><code>import win32com.client
  
  word = win32com.client.Dispatch("Word.Application")
  doc = word.Documents.Open(your_doc_path)
  contents = 'What here?'  # doc.Content?
  
  outlook = win32com.client.Dispatch("Outlook.Application")
  # Create a new MailItem object
  msg = outlook.CreateItem(0)
  
  msg.Body = 'What here?'  # `contents` throws pywintypes.com_error
  msg.Display(False)
  </code></pre>
  
  <p><strong>The closest problems:</strong></p>
  
  <p><a href="https://stackoverflow.com/questions/4628208/copy-word-format-into-outlook-message">Copy Word format into Outlook message</a></p>
  
  <p><a href="https://social.msdn.microsoft.com/Forums/office/en-US/ff6a5a9f-30db-4e14-be81-73f03b3b53d1/a-word-documents-contents-as-the-body-of-an-email-meassage?forum=outlookdev" rel="nofollow noreferrer">A word document's contents as the body of an email message</a></p>
  
  <p><a href="https://stackoverflow.com/questions/32850485/how-to-paste-into-outlook-from-microsoft-word">How to paste into Outlook from Microsoft Word</a></p>
  
  <p><a href="https://stackoverflow.com/questions/24245127/exporting-rich-text-to-outlook-and-keep-formatting">Exporting rich text to outlook and keep formatting</a></p>
  
  <p><strong>Does not work:</strong></p>
  
  <p>1-Saving a Word doc as HTML (analogously RTF) and </p>
  
  <pre><code>with open(html_path, 'r', errors='ignore') as f:
      # Possible UnicodeDecodeError
      doc_body = f.read()
  
      msg.BodyFormat = 2  # olFormatHTML
      msg.Body = doc_body
  </code></pre>
  
  <p>2-Reading document.xml in the zipped Word document.</p>
  
  <p>Possible way:</p>
  
  <blockquote>
    <p>The WordEditor property of the Inspector class returns an instance of
    the Word Document which represents the message body.</p>
  </blockquote>
  
  <p>How to apply WordEditor via win32com?</p>