问题描述
我有一些代码可以使用 Windows 上的默认电子邮件客户端发送电子邮件.
I have some code that sends emails using the default email client on windows.
如果是 Outlook,我将使用Outlook.Application"ole 对象,否则我将回退到 MAPI.这已在多个站点使用多年,但现在不适用于新客户.
If it's Outlook, I'll use the "Outlook.Application" ole object, otherwise I'll fall back to MAPI.This has been in use at multiple sites for several years, but now it is not working for a new client.
/* Pseudocode Delphi */
client = HKEY_CURRENT_USER\Software\Clients\Mail
if client='' then client=HKEY_LOCAL_MACHINE\Software\Clients\Mail
if pos('Outlook',client)>0 then useoutlook:=true;
if useoutlook then OutApp:=CreateOleObject('Outlook.Application');
else UseMapi
这种方法在使用 Win 10 和 Outlook 2016 MSO (16.0.11901.20070) 32 位时存在两个问题
There are two problems with this approach using Win 10 and Outlook 2016 MSO (16.0.11901.20070) 32 bit
- 从注册表读取返回的是 PackagedMail ...我不知道这是什么,也找不到任何相关信息.
- Outlook.Application 未包含在注册的类中
- MAPI 返回 MAPI 000001 不正确的函数错误
我在网上找到了一些线索,表明 Outlook 中的 MAPI 依赖于 Outlook.Application OLE.
I've found some clues online indicating that MAPI in outlook relies on the Outlook.Application OLE.
我只需要知道如何强制它安装 OLE 类,或者为 MAPI 正确注册它,或者知道它是否不再受支持,我需要找到不同的解决方案.
I just need to either know how for force it to install the OLE class, OR register it properly for MAPI, OR to know if it's no longer supported and I need to find a different solution.
我要做的就是发送带有 pdf 附件的电子邮件.我发现 Outlook 的 MAPI 支持似乎有点古怪,我最好使用 OLE,但如果它不再受支持或需要额外的步骤,我需要知道.
All I'm trying to do is to send an email with a pdf attachment. I found that Outlook's MAPI support seemed a little flakey and I was better off using the OLE, but if it's no longer supported or needs extra steps, I need to know.
如果有人对 PackagedMail 有任何详细信息,那就太好了.
If anyone has any detail on PackagedMail, that would be a bonus.
推荐答案
解决了我眼前问题的部分答案:
Partial answer which resolved my immediate problem:
Delphi Winapi.Mapi 单元检查注册表以查看是否安装了 MAPI:
The Delphi Winapi.Mapi unit checks the registry to see if MAPI is installed:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Messaging Subsystem
MAPI="1"
这在 Regedit 中清晰可见并填充,但由于 注册表重定向
This was clearly visible and populated in Regedit, but not visible to Delphi due to Registry Redirection
3 个 2 位应用程序看到的实际注册表项存储在这里:
The actual registry key that 3 2bit applications see is stored here:
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows Messaging Subsystem
由于某种原因没有填充.手动将 MAPI="1" 添加到 WOW6432Node 条目使 MAPI 功能重新开始工作.
which was NOT populated for some reason. Manually adding MAPI="1" into the WOW6432Node entry made the MAPI features start working again.
这仍然没有回答我的实际问题,但我认为值得记录.
This still doesn't answer my actual question, but I thought it worth documenting.
注意:MAPI 值为 REGSZ(字符串)类型.
NOTE: The MAPI value is a REGSZ (String) type.
这篇关于Outlook.Application 组件在 Outlook 2016 中是否仍受支持?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!