[英]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.