Hi,<br><br>I am try to print all the message in my mailbox . its not working <br>inbox = session.Inbox<br>i print the value of inbox its gives <COMObject <unknown>><br>I think its not getting the inbox ?<br><br>
<code><br>#<br># inbox.py<br># test case for access to Exchange; run through the<br># hard-coded user's inbox and list the subjects of each email.<br>#<br><br>import win32com.client<br>session = win32com.client.gencache
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">.EnsureDispatch ("MAPI.Session")<br>session.Logon ()<br></blockquote><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
inbox = session.Inbox</blockquote><div>print inbox<br><br>when I try to print the inbox :<br>inbox = <COMObject <uknown>><br><br>can anybody tell whats wrong in Outlook.?<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>messages = inbox.Messages<br>message = messages.GetFirst ()<br>while message:<br> print "subject: ", message.Subject<br> message = messages.GetNext ()<br><br>session.Logoff ()<br><br></code></blockquote>
<br><br><br><div class="gmail_quote">On Dec 21, 2007 4:30 PM, <<a href="mailto:python-win32-request@python.org">python-win32-request@python.org</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Send python-win32 mailing list submissions to<br> <a href="mailto:python-win32@python.org">python-win32@python.org</a><br><br>To subscribe or unsubscribe via the World Wide Web, visit<br> <a href="http://mail.python.org/mailman/listinfo/python-win32" target="_blank">
http://mail.python.org/mailman/listinfo/python-win32</a><br>or, via email, send a message with subject or body 'help' to<br> <a href="mailto:python-win32-request@python.org">python-win32-request@python.org</a>
<br><br>You can reach the person managing the list at<br> <a href="mailto:python-win32-owner@python.org">python-win32-owner@python.org</a><br><br>When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of python-win32 digest..."<br><br><br>Today's Topics:<br><br> 1. how to get mails from Outlook (Antony Joseph)<br> 2. Re: how to get mails from Outlook (Tim Golden)<br> 3. Operational errorr : (Antony Joseph)
<br> 4. Re: Operational errorr : (Tim Golden)<br><br><br>----------------------------------------------------------------------<br><br>Message: 1<br>Date: Fri, 21 Dec 2007 12:03:27 +0530<br>From: "Antony Joseph" <
<a href="mailto:antonyjoseph89@gmail.com">antonyjoseph89@gmail.com</a>><br>Subject: [python-win32] how to get mails from Outlook<br>To: <a href="mailto:python-win32@python.org">python-win32@python.org</a><br>Message-ID:
<br> <<a href="mailto:f14c4c340712202233ua179a9dk56401d863275d930@mail.gmail.com">f14c4c340712202233ua179a9dk56401d863275d930@mail.gmail.com</a>><br>Content-Type: text/plain; charset="iso-8859-1"<br>
<br>hi,<br><br>I am trying to read all the mails in the Inbox from outlook and convert<br>those mails into text format in my local path.<br><br>Is there any tutorials or any links that can be usefull to me.<br><br>Thanks<br>
-------------- next part --------------<br>An HTML attachment was scrubbed...<br>URL: <a href="http://mail.python.org/pipermail/python-win32/attachments/20071221/516acd01/attachment-0001.htm" target="_blank">http://mail.python.org/pipermail/python-win32/attachments/20071221/516acd01/attachment-0001.htm
</a><br><br>------------------------------<br><br>Message: 2<br>Date: Fri, 21 Dec 2007 08:42:21 +0000<br>From: Tim Golden <<a href="mailto:mail@timgolden.me.uk">mail@timgolden.me.uk</a>><br>Subject: Re: [python-win32] how to get mails from Outlook
<br>Cc: <a href="mailto:python-win32@python.org">python-win32@python.org</a><br>Message-ID: <<a href="mailto:476B7C6D.2090400@timgolden.me.uk">476B7C6D.2090400@timgolden.me.uk</a>><br>Content-Type: text/plain; charset=ISO-8859-1; format=flowed
<br><br>Antony Joseph wrote:<br>> hi,<br>><br>> I am trying to read all the mails in the Inbox from outlook and convert<br>> those mails into text format in my local path.<br>><br>> Is there any tutorials or any links that can be usefull to me.
<br><br>Here's an absolutely Noddy example to get you going:<br><br><code><br>#<br># inbox.py<br># test case for access to Exchange; run through the<br># hard-coded user's inbox and list the subjects of each email.
<br>#<br><br>import win32com.client<br><br>session = win32com.client.gencache.EnsureDispatch ("MAPI.Session")<br>session.Logon ()<br><br>inbox = session.Inbox<br>messages = inbox.Messages<br>message = messages.GetFirst
()<br>while message:<br> print "subject: ", message.Subject<br> message = messages.GetNext ()<br><br>session.Logoff ()<br><br></code><br><br>and, aside from the MSDN docs on MAPI.Session, the keyword<br>
you're looking for is CDO. Here's a couple of useful sites:<br><br><a href="http://www.outlookcode.com/article.aspx?id=20" target="_blank">http://www.outlookcode.com/article.aspx?id=20</a><br><a href="http://www.cdolive.com/default.htm" target="_blank">
http://www.cdolive.com/default.htm</a><br><br>BTW, this is all relatively old stuff (although it still works<br>fine on my XP-Outlook2003-Exchangewhatever setup). There may<br>well be some "preferred" MSActiveNETMailProvider [*] technique
<br>which is more future-proofed.<br><br>If you need more info feel to come back and ask.<br><br>TJG<br><br>[*] Invented, obviously; don't go searching for it!<br><br><br>------------------------------<br><br>Message: 3
<br>Date: Fri, 21 Dec 2007 14:42:39 +0530<br>From: "Antony Joseph" <<a href="mailto:antonyjoseph89@gmail.com">antonyjoseph89@gmail.com</a>><br>Subject: [python-win32] Operational errorr :<br>To: <a href="mailto:python-win32@python.org">
python-win32@python.org</a><br>Message-ID:<br> <<a href="mailto:f14c4c340712210112u70b27bbdx39577736a60e66df@mail.gmail.com">f14c4c340712210112u70b27bbdx39577736a60e66df@mail.gmail.com</a>><br>Content-Type: text/plain; charset="iso-8859-1"
<br><br>I am getting Operational Error : when i try get my contacts .<br><br>My code :<br>import win32com.client<br>oOutlook = win32com.client.gencache.EnsureDispatch("Outlook.Application")<br>onMAPI = oOutlook.GetNamespace
("MAPI")<br>ofContacts = onMAPI.GetDefaultFolder(10) # 10=outlook contacts folder<br>redemption = oOutlook.CreateObject('Redemption.SafeContactItem')<br>for i in range(len(ofContacts.Items)):<br> redemption.Item
= ofContacts.Items.Item(i+1)<br> print redemption.Subject<br><br>can any one tell me , what i am doing error or please tell me to solve this<br>problem.<br><br><br>My Error:<br><br> File "m1.py", line 5, in <module>
<br> redemption = oOutlook.CreateObject('Redemption.SafeContactItem')<br> File<br>"C:\Python25\lib\site-packages\win32com\gen_py\00062FFF-0000-0000-C000-00<br>0000000046x0x9x3\_Application.py", line 82, in CreateObject
<br> ret = self._oleobj_.InvokeTypes(277, LCID, 1, (9, 0), ((8,<br>1),),ObjectName<br>pywintypes.com_error: (-2147352567, 'Exception occurred.', (4096, 'Microsoft<br>Off<br>ice Outlook', 'The operation failed.', None, 0, -2147221005), None)
<br><br><br>Antony<br>-------------- next part --------------<br>An HTML attachment was scrubbed...<br>URL: <a href="http://mail.python.org/pipermail/python-win32/attachments/20071221/c9e399c0/attachment-0001.htm" target="_blank">
http://mail.python.org/pipermail/python-win32/attachments/20071221/c9e399c0/attachment-0001.htm</a><br><br>------------------------------<br><br>Message: 4<br>Date: Fri, 21 Dec 2007 09:41:19 +0000<br>From: Tim Golden <
<a href="mailto:mail@timgolden.me.uk">mail@timgolden.me.uk</a>><br>Subject: Re: [python-win32] Operational errorr :<br>Cc: <a href="mailto:python-win32@python.org">python-win32@python.org</a><br>Message-ID: <<a href="mailto:476B8A3F.4090107@timgolden.me.uk">
476B8A3F.4090107@timgolden.me.uk</a>><br>Content-Type: text/plain; charset=ISO-8859-1; format=flowed<br><br>Antony Joseph wrote:<br>> I am getting Operational Error : when i try get my contacts .<br>><br>> My code :
<br>> import win32com.client<br>> oOutlook = win32com.client.gencache.EnsureDispatch("Outlook.Application")<br>> onMAPI = oOutlook.GetNamespace("MAPI")<br>> ofContacts = onMAPI.GetDefaultFolder
(10) # 10=outlook contacts folder<br>> redemption = oOutlook.CreateObject('Redemption.SafeContactItem')<br><br>Well your error's coming from this line, but for the life<br>of me I can't work out what you're trying to do with it,
<br>since it's not used anywhere else. The MSDN help for Outlook<br>_Application.CreateObject [1] suggests that it's a placeholder for<br>other methods of creating objects. Maybe you're trying to use<br>.CreateItem [2] which seems to be used for creating new contact
<br>items.<br><br>> for i in range(len(ofContacts.Items)):<br>> redemption.Item = ofContacts.Items.Item(i+1)<br>> print redemption.Subject<br><br>Ah, I think I see. You're trying to create a contact which
<br>then appears in the list this displays. I think you'll need<br>to save it first with some details as per the Technet link<br>below {[2]).<br><br>TJG<br><br>[1]<br><a href="http://msdn2.microsoft.com/en-us/library/microsoft.office.interop.outlook._application.createobject.aspx" target="_blank">
http://msdn2.microsoft.com/en-us/library/microsoft.office.interop.outlook._application.createobject.aspx</a><br>[2]<br><a href="http://www.microsoft.com/technet/scriptcenter/resources/officetips/apr05/tips0426.mspx" target="_blank">
http://www.microsoft.com/technet/scriptcenter/resources/officetips/apr05/tips0426.mspx</a><br><br><br><br>------------------------------<br><br>_______________________________________________<br>python-win32 mailing list<br>
<a href="mailto:python-win32@python.org">python-win32@python.org</a><br><a href="http://mail.python.org/mailman/listinfo/python-win32" target="_blank">http://mail.python.org/mailman/listinfo/python-win32</a><br><br><br>End of python-win32 Digest, Vol 57, Issue 22
<br>********************************************<br></blockquote></div><br>