title: Python - copy range in Excel as image and paste in body of outlook email
body: <p>I'm very new to Python - I'm having issues copying a range in excel as an image and pasting that image in the body of an Outlook email. Please see my code below:</p>
  
  <pre><code>import win32com.client as win32
  from PIL import ImageGrab
  
  xlApp = win32.gencache.EnsureDispatch('Excel.Application')
  
  
  wb = xlApp.Workbooks.Open('U:\Reporting\Templates\Daily_Update_Template_v3.xlsm')
  ws = wb.Worksheets('Summary')
  win32c = win32.constants
  ws.Range(ws.Cells(1,1),ws.Cells(83,14)).CopyPicture(Format= win32c.xlBitmap)
  img = ImageGrab.grabclipboard()
  
  Message = 'Hello World!'
  
  outlook = win32.Dispatch('outlook.application')
  mail = outlook.CreateItem(0)
  mail.To = 'email@blaaaaa.com'
  mail.Subject = 'Test'
  mail.Body = img
  
  
  mail.Send()
  </code></pre>
  
  <p>When I run the script, I receive the error the following error:</p>
  
  <blockquote>
    <p>TypeError: Objects of type 'DibImageFile' can not be converted to a
    COM VARIANT (but obtaining the buffer() of this object could)</p>
  </blockquote>
  
  <p>Can anyone help me understand? Thanks!</p>