简体   繁体   English

win32com.client.dispatch("Redemption.RDOSession") 使用特定目录中的 dll

[英]win32com.client.dispatch("Redemption.RDOSession") to use dll from a specific directory

I am currently attempting to create an email using redemption in python.我目前正在尝试使用 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.我可以在我的机器上安装赎回来完成创建,但是在将使用它的虚拟会话中,赎回 dll 位于不同的目录中。 Is there a way to specify the directory used in the win32com.client.Dispatch("Redemption.RDOSession")?有没有办法指定 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:我期待它使用定向 dll 创建会话,但出现以下错误:

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")

win32com.client.Dispatch expects the COM registration name (as specified in HKCR registry hive), not a path to a dll implementing that COM object. win32com.client.Dispatch需要 COM 注册名称(在 HKCR 注册表配置单元中指定),而不是实现该 COM 对象的 dll 的路径。

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")通过从命令行运行regsvr32.exe <full path to>\redemption.dll确保安装 Redemption,然后您可以简单地使用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.使用 RedemptionLoader 无需 COM 注册即可使用Redemption ,但它仅适用于 C++/C#/Delphi/VB.Net,不适用于 Python。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 非阻塞win32com.client.Dispatch - Non blocking win32com.client.Dispatch win32com.client.Dispatch类标签 - win32com.client.Dispatch Class Label win32com.client.Dispatch 打开不需要的独木舟版本 - win32com.client.Dispatch opening the undesired canoe version 使用 win32com.client.Dispatch() 读取 .doc 文件 - Reading .doc file using win32com.client.Dispatch() 如何从win32com.client.dispatch获取属性(“Shell.Application”) - how to get attributes from win32com.client.dispatch(“Shell.Application”) “调用的对象已与其客户端断开连接”win32com.client.Dispatch(&#39;CANalyzer.Application&#39;) - “The object invoked has disconnected from its clients” win32com.client.Dispatch('CANalyzer.Application') win32com.client.Dispatch有效,但不是win32com.client.gencache.EnsureDispatch - win32com.client.Dispatch works but not win32com.client.gencache.EnsureDispatch python的win32com.client.dispatch()无法识别已注册的COM对象 - Registered COM object not recognized by python's win32com.client.dispatch() 使用 win32com.client.dispatch 函数在 python 中打开 Excel 和 Word 时的不同行为 - Different behaviour when opening Excel and Word in python using win32com.client.dispatch function win32com.client.Dispatch + Cherrypy = CoInitialize 没有被调用 - win32com.client.Dispatch + Cherrypy = CoInitialize has not been called
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM