0

I am currently attempting to create an email using redemption in python. I am able to complete the creation with redemption installed on my machine, but on the virtual sessions where this will be used, the redemption dll is in a different directory. Is there a way to specify the directory used in the win32com.client.Dispatch("Redemption.RDOSession") ?

search_string = 'genericemail@gmail.com'

outlook = win32com.client.gencache.EnsureDispatch("Outlook.Application")
redemption = win32com.client.Dispatch("C:\Users\CorruptionINC\Redemption\Redemption64.dll", "Redemption.RDOSession")

redemption.Logon()
draft_folder = redemption.GetDefaultFolder(16)
message = draft_folder.Items.Add()
message.save()
recipient = message.Recipients.Add(search_string)
recipient.Resolve()

I was expecting it to create an session using the directed dll, but I get the following error:

Exception has occurred: com_error
(-2147221005, 'Invalid class string', None, None)

During handling of the above exception, another exception occurred:

  File "C:\Users\CorruptionINC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\Scripts\OutlookContacts.py", line 28, in <module>
    redemption = win32com.client.Dispatch("C:\Users\CorruptionINC\Redemption\Redemption64.dll", "Redemption.RDOSession")
STerliakov
  • 4,983
  • 3
  • 15
  • 37

1 Answers1

0

win32com.client.Dispatch expects the COM registration name (as specified in HKCR registry hive), not a path to a dll implementing that COM object.

Make sure Redemption is installed by running regsvr32.exe <full path to>\redemption.dll from command line, you can then simply use win32com.client.Dispatch("Redemption.RDOSession")

Redemption can be used without COM registration using RedemptionLoader, but it is only available in C++/C#/Delphi/VB.Net, not Python.

Dmitry Streblechenko
  • 62,942
  • 4
  • 53
  • 78
  • The code works with the Redemption64.dll installed in the proper directory. The issue is that other computers running this code will not have this installed and will not allow redemption to be installed. I was hoping to access these COM objects from the network copy of the redemption dll or a c drive location that will allow me to copy the dll from the network to a set directory each time the code is run. – CorruptionINC Dec 15 '22 at 18:18
  • OK then, I don't think I understand the question then - if you copy the dll to a folder whcih is not user-specific (e.g, "c:\redemption"), why wouldn't than work? – Dmitry Streblechenko Dec 16 '22 at 16:15
  • I figured out the issue. I was allowing Redemption to install on my computer into the Program x86, which is where win32com was looking for the DLL when opening the session. When I directed it to use the directory that I was going to use on the other computers, it started using that directory on the other computers as well. – CorruptionINC Dec 19 '22 at 10:01