Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Difference in versions of OS/Outlook/CDO is what might be the source of confusion, so here are the steps to get it working on WinXP/Outlook 2007/CDO 1.21:</p> <ul> <li>install <a href="http://www.microsoft.com/downloads/details.aspx?familyid=2714320d-c997-4de1-986f-24f081725d36&amp;displaylang=en" rel="nofollow noreferrer">CDO 1.21</a></li> <li>install win32com.client</li> <li>goto C:\Python25\Lib\site-packages\win32com\client\ directory run the following:</li> </ul> <pre>python makepy.py</pre> <ul> <li>from the list select "Microsoft CDO 1.21 Library (1.21)", click ok</li> </ul> <pre>C:\Python25\Lib\site-packages\win32com\client>python makepy.py Generating to C:\Python25\lib\site-packages\win32com\gen_py\3FA7DEA7-6438-101B-ACC1-00AA00423326x0x1x33.py Building definitions from type library... Generating... Importing module</pre> <ul> <li>Examining file 3FA7DEA7-6438-101B-ACC1-00AA00423326x0x1x33.py that's just been generated, will give you an idea of what classes, methods, properties and constants are available.</li> </ul> <p>Now that we are done with the boring steps, here is the fun part:</p> <pre><code>import win32com.client from win32com.client import Dispatch session = Dispatch('MAPI.session') session.Logon ('Outlook') # this is profile name inbox = session.Inbox messages = session.Inbox.Messages message = inbox.Messages.GetFirst() if(message): attachments = message.Attachments for i in range(attachments.Count): attachment = attachments.Item(i + 1) # yep, indexes are 1 based filename = "c:\\tmpfile" + str(i) attachment.WriteToFile(FileName=filename) session.Logoff() </code></pre> <p>Same general approach will also work if you have older version of CDO (CDO for win2k)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload