Jürgen Kareta wrote:
> Hello,
> 
> I'm trying to get some email addresses with the following pythoncode:
> 
> import win32com.client
> O = win32com.client.gencache.EnsureDispatch('Outlook.Application')
> mapi=O.GetNamespace('MAPI')
> adr_li=mapi.AddressLists.Item('Global Addressbook')
> members=adr_li.AddressEntries.Item('MyGroup').Members
> for num in range(0, members.__len__()-1):
>     name=entr.GetNext()
>     print name.Name,name.Address
> 
entr.GetNext? Is it possible you aren't dealing with what you think you 
are dealing with? Don't see any other reference to this in your code.

> That works fine, except that I get the x400 address:
>     paul panther /o=panter group/ou=venus/cn=Recipients/cn=PaulP
> instead of the expected SMTP adress:
>     [EMAIL PROTECTED]
> 
> How can I get the SMPT addresses ?
> 

  >>> members = "iterable"
  >>> members.__len__()
8
  >>> len(members)
8
  >>> range(0, 8-1)
[0, 1, 2, 3, 4, 5, 6]
  >>> range(8)
[0, 1, 2, 3, 4, 5, 6, 7]
  >>> [members[x] for x in range(0, members.__len__()-1)]
['i', 't', 'e', 'r', 'a', 'b', 'l']
                                  ^^^
                       ??? no "e" ???
  >>> [x for x in members]
['i', 't', 'e', 'r', 'a', 'b', 'l', 'e']
  >>>

Try:

for num in range(len(members)):
     name=entr.GetNext()
     print name.Name,name.Address

Seems to me like the X.400 address may be just the first one, and your 
code is accidentally not handling the last (second, Internet) address.

If members is being wrapped by pythoncom as a Python iterable then you 
might be able to get away with (something like, untested):

for entry in adr_li.AddressEntries.Item('MyGroup').Members:
   for name in entry.Members:
     print name.Name,name.Address

HTH. Just a few ideas.

regards
  Steve
-- 
Steve Holden        +1 703 861 4237  +1 800 494 3119
Holden Web LLC             http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
_______________________________________________
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to