问题标签 [com-automation]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
150 浏览

windows - IGlobalInterfaceTable::RegisterInterfaceInGlobal 返回零 cookie

我正在尝试重新打包一个由多个库、COM 接口和一个 COM 自动化服务器组成的专有应用程序。

我的精简发行版不起作用。

使用函数调用监视器(RohitLab API 监视器),我已经确定对 IGlobalInterfaceTable::RegisterInterfaceInGlobal 的调用会为剥离版本中的 cookie 返回零值;在正确的完整安装中,它总是返回 256。

文档说“无效 cookie 的值为 0”。

这很有趣,但是应用程序忽略了零返回值并使用 256 代替(总是?)用于 IGlobalInterfaceTable::GetInterfaceFromGlobal,并且稍后不起作用,因为它试图将接口返回的 NULL 指针连接到其他 COM 对象.

它不会崩溃,只是不会按预期工作。

问题:为什么 RegisterInterfaceInGlobal 会返回零值?包含此接口类型库的 dll 使用 regsvr32 注册。顺便说一句,它似乎加载了另一个 dll,它也是一个 COM 库,但其中没有类型库。

0 投票
0 回答
530 浏览

c# - Issues with creating a C# .NET User Defined Function

I am investigating creating an Automation AddIn for Excel as an alternative to Excel DNA. Referencing the article by Adam Tibi (http://www.adamtibi.net/07-2012/using-c-sharp-net-user-defined-functions-udf-in-excel), I was able to get a class library to work with some issues. The largest issue is that the formula does work but does not show in the list of Excel formulas. Additionally, I would like to have intellisense on the UDF parameters, and would also like to know if there is any way to capture the cell references of where the formula was sent from.

In terms of setup, I have made selected the "Make Assembly COM Visible" and the "Register for COM interop".

Code-wise, I have the following classes.

and

When I attempt to take a Excel VSTO addin and apply the same techniques, I can get it to build by doing everything the same except for selecting "Register for COM interop".

My development environment is Windows 10, Excel for Office 365 64-bit, Visual Studio Professional 2017 Version 15.9.7. My Excel Addin will need to support 2010, 2013, 2016 2019, and Office 365.

I would like to have the function appear in the list of functions and to also create a category for it to appear under, but do not know how.

Any help would be greatly appreciated.

Edit 1

I figured out how to determine the range that the UDF was called from. Interestingly enough, the application does not get preserved even when I attempt to keep it in a static class/variable/property. I was setting the application in the ThisAddIn.cs within the ThisAddIn_Startup method, but the application was null when I tried to access it within the COM Automation method.

In the COM Automation class mentioned above, the references may be found as follows below.

My questions at this point are as follows: 1. How to get the UDF to show when the user starts typing. 2. How to get intellisense working on the UDF parameters. 3. How to preserve the application.

0 投票
4 回答
6133 浏览

python - 使用 PasteExcelTable 将 Excel 数据复制到带有 Python 的 Outlook 电子邮件正文

格式化的 Excel 范围复制到 Word 文件

这会从 Excel 复制一系列单元格并将它们粘贴到保留格式的 Word 文档中。该代码适用于此。但是,我还想将数据粘贴到带有单元格样式的电子邮件正文中。

我相信[PasteExcelTable] 2可用于在 Outlook 中实现这一点,就像它对 Word 文件所做的那样,也许有人知道如何做到这一点。

我没有正确定义范围。这是我尝试之一的示例:

我知道这可以通过 VBA 完成,但我想使用 Python 并查看 PasteExcelTable 是否适用于此。如果不可能,我将捕获数据范围的图像并将其粘贴到电子邮件中。

0 投票
2 回答
112 浏览

vba - 从 Office.Interop.Outlook 迁移

我们目前使用 Microsoft.Office.Interop.Outlook 来打开带有预格式化 MailItem 的 Outlook。这样用户就可以在发送电子邮件之前更改任何信息。

已搜索 Exchange WebServices,但未找到等效项。

我尽可能地清理了下面的代码。我们想在我们的用户桌面上的当前版本的 Outlook 中打开一条消息。目前,我们有 Exchange on prem 和 Office 2010,我们正在迁移到云中的 Office 2016 和 O365。

寻找任何 .Net 方法来执行等效操作。

0 投票
1 回答
231 浏览

c# - C# Attach 打开 Outlook 电子邮件、编辑和发送

我正在尝试在已经运行的 Outlook 实例(由用户手动打开)上将一些 C# 附加到打开的回复电子邮件(由用户手动触发)。代码应识别打开的回复电子邮件,编辑电子邮件的主题行和正文并发送电子邮件。

问题是我尽可能识别 Outlook 的运行实例并使用其中一种 Marshal 方法将其分配给对象outApp = Marshal.GetActiveObject("Outlook.Application") as Application,但是我无法将其转换为 MailItem 类型以操作其元素,例如主题行、正文等...类似的东西MailItem mailItem = (MailItem)outApp.CreateItem((OlItemType.olMailItem));在运行时抛出一个无效的强制转换异常。

抱歉,如果我错了,但找不到与此确切事件序列相近的单个示例,其中一个更接近的示例是此帖子c# Outlook 打开现有实例并回复电子邮件 ,但它采用了完全不同的方式。有大量关于如何使用 Microsoft.Office.Interop.Outlook 来打开然后使用 Outlook 实例的帖子,但几乎没有(我能找到)关于如何使用打开实例的文章。任何帮助表示赞赏,谢谢。

编辑 08102019:
该代码是从 RPA 平台使用的,因此不存在将其作为恶意软件提取的风险。“用户”只是具有特制权限和受控环境的帐户上的虚拟用户......对不起,这里没有什么黑暗的:-)。无论如何,这是我目前正在使用的代码,它创建一个新实例并将其保存到 Outlook 中的草稿中。这不是我打算做的,正如我上面解释的,这只是一个临时修复:

0 投票
1 回答
203 浏览

image - Perl - Outlook - 将嵌入图像包含在电子邮件正文中(HTML)

我需要将图像包含到电子邮件正文中(使用 HTML 格式),以便将其嵌入,而不是使用 Perl 中的库 Win32::OLE 调用安装在 Windows 上的 Outlook 客户端的额外附件。

下面的代码有效,但收到的电子邮件不显示图像。我可以看到唯一的一个小方形符号,表示内嵌嵌入图像丢失或损坏。

有人知道上面的代码有什么问题吗?任何建议都将受到高度赞赏。

0 投票
1 回答
1282 浏览

python - 通过 Python 发送带有隐藏/不同发件人姓名的 Outlook 电子邮件?

我正在进行一个使用 python 的商业项目,我的团队将在某些团队中发送自动报告。发送它的代码效果很好:

感谢这个线程:通过 Python 发送 Outlook 电子邮件?

无论如何要更改发件人的地址,例如:

否则问题将是人们会将邮件回复到我的电子邮件地址,这将是错误的做法。或者这根本不可能,因为它必须打开我的 Outlook 帐户?

0 投票
2 回答
2075 浏览

python - 按标题在 Outlook 中查找特定邮件

我正在尝试创建一个代码,该代码将使用主题字段在我的邮箱中查找信件(例如,根据 Outlook 规则,这些信件将位于文件夹“TODO”中)。这就是我现在所拥有的:

此代码查找文件夹中的最后一个字母。

先感谢您。

0 投票
2 回答
98 浏览

excel - 在 excel vba、OLE 问题上发送大量电子邮件

我希望你做得很好。

我正在使用此代码在 VBA Excel 中发送电子邮件,但它只能工作一次,然后我必须在任务管理器上关闭 Outlook。如果我不这样做,我会收到一条消息“Microsoft Excel 正在等待另一个应用程序完成 OLE 操作”。我唯一需要做的就是关闭任务管理器上的 Outlook 应用程序,然后它就可以正常工作了。

你能帮我解决这个问题吗?下面我将发布我的代码

非常感谢您的时间和帮助。

0 投票
1 回答
147 浏览

r - Outlook$CreateItem(0) 使 R 崩溃(使用包 RDCOMClient)

我解决了这个问题,但在这里记录以防有人在使用 RDCOMClient 通过 R 发送 Outlook 电子邮件时遇到困难。

使用全新安装的 Windows 10 Pro for Workstations 作为 VirtualBox VM、R 版本 4.1.1、Rstudio 2021.09.0(内部版本 351)和 Microsoft Office365 Outlook 客户端(版本 2102(内部版本 13801.20960 即点即用))。

以下代码导致 R 每次在最后一行崩溃:

我将 R 版本回滚到 3.5.1——它现在可以工作了。

结论:RDCOMClient 与最新版本的 R (4.1.1) 不兼容。