J
Jeff Miller
Hello,
I have been hitting my head against the wall for hours now. For the
life of me, I can't figure out whats wrong with my script... I have a
test script that interacts with CDO to access Microsoft Exchange, as
follows:
require 'win32ole'
#~ START MAPI/CDO SESSION
session = WIN32OLE.new('Mapi.session')
session.logon("username", "password")
#~ GET A LIST OF MAILBOXES TO ITERATE OVER
address_list = session.GetAddressList(0)
address_entry = address_list.AddressEntries
#~ INITIATE NEW MAPI SESSION (FOR DYNAMIC LOGONS)
newsession = WIN32OLE.new('Mapi.session')
#~ ITERATE OVER ALL MAILBOXES
address_entry.each do |row|
profileInfo = "EX" + "\n" + row.Name
newsession.logon("", "", "FALSE", "TRUE", "0", "TRUE", profileInfo)
#~ EXCEPTION HANDLING
begin
contacts_folder = newsession.GetDefaultFolder(5)
puts newsession.CurrentUser.Name
rescue Exception => blah
puts "DISABLED"
puts blah.inspect
ensure
newsession.logoff
end
end
session.Logoff
Basically, the error comes out of the exception handling portion. When I
comment it out and put "puts newsession.CurrentUser.Name" it gives me
what I want - which is the script accessing every mailbox on Exchange.
The error handling says that if GetDefaultFolder(5) (which is the
Contacts Folder in Outlook) doesn't exist, then that user is disabled,
so skip to the next user. For some reason, with the error handling
section in there, it never outputs consistent data. It could list 5 or 6
users, then, without changing anything and just running it again, it'll
give me 100 users. The message it gives me is as follows:
test_mapisession.rb:42: [BUG] Segmentation fault
ruby 1.8.6 (2007-09-24) [i386-mswin32]
This application has requested the Runtime to terminate it in an unusual
way.
Please contact the application's support team for more information.
line 42 of my code is the "newsession.logoff" that is in the ensure
clause of the error handling statement. Does anybody know what is going
on? I have never encountered a Segmentation fault... I am lost on this,
so any and all help is appreciated!
Thanks!!!
- Jeff Miller
I have been hitting my head against the wall for hours now. For the
life of me, I can't figure out whats wrong with my script... I have a
test script that interacts with CDO to access Microsoft Exchange, as
follows:
require 'win32ole'
#~ START MAPI/CDO SESSION
session = WIN32OLE.new('Mapi.session')
session.logon("username", "password")
#~ GET A LIST OF MAILBOXES TO ITERATE OVER
address_list = session.GetAddressList(0)
address_entry = address_list.AddressEntries
#~ INITIATE NEW MAPI SESSION (FOR DYNAMIC LOGONS)
newsession = WIN32OLE.new('Mapi.session')
#~ ITERATE OVER ALL MAILBOXES
address_entry.each do |row|
profileInfo = "EX" + "\n" + row.Name
newsession.logon("", "", "FALSE", "TRUE", "0", "TRUE", profileInfo)
#~ EXCEPTION HANDLING
begin
contacts_folder = newsession.GetDefaultFolder(5)
puts newsession.CurrentUser.Name
rescue Exception => blah
puts "DISABLED"
puts blah.inspect
ensure
newsession.logoff
end
end
session.Logoff
Basically, the error comes out of the exception handling portion. When I
comment it out and put "puts newsession.CurrentUser.Name" it gives me
what I want - which is the script accessing every mailbox on Exchange.
The error handling says that if GetDefaultFolder(5) (which is the
Contacts Folder in Outlook) doesn't exist, then that user is disabled,
so skip to the next user. For some reason, with the error handling
section in there, it never outputs consistent data. It could list 5 or 6
users, then, without changing anything and just running it again, it'll
give me 100 users. The message it gives me is as follows:
test_mapisession.rb:42: [BUG] Segmentation fault
ruby 1.8.6 (2007-09-24) [i386-mswin32]
This application has requested the Runtime to terminate it in an unusual
way.
Please contact the application's support team for more information.
line 42 of my code is the "newsession.logoff" that is in the ensure
clause of the error handling statement. Does anybody know what is going
on? I have never encountered a Segmentation fault... I am lost on this,
so any and all help is appreciated!
Thanks!!!
- Jeff Miller