MAPI和托管代码体验? [英] MAPI and managed code experiences?

查看:151
本文介绍了MAPI和托管代码体验?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在托管代码中使用MAPI功能官方不受支持。显然,MAPI使用自己的内存管理,并在托管代码中崩溃和刻录(请参阅这里 here



我想做的是启动主题,正文,和一个或多个附件的默认电子邮件客户端



所以我一直在研究 MAPISendDocuments 它似乎工作。但是我没有能力在生产代码中实际使用该功能。



有没有人使用过这个功能呢?你有什么恐怖故事吗?



PS。不,我不会shellExecute Outlook.exe与附件的命令行参数。



PPS。附件支持是一个需求,所以Mailto:解决方案不会为我而切。

解决方案

有一个单独的助手EXE,它接受命令行参数(或管道到其StandardInput),执行所需的操作,并从主应用程序调用该参数。这将使MAPI的内容不在主应用程序的进程空间之外。好的,你还在混合MAPI和.NET,但是在一个非常短暂的过程中。假设MAPI和CLR开始导致长时间运行的进程的问题。



我们使用Dmitry Streblechenko的精湛的赎回数据对象库,允许我们在JScript中编写这样的垫片代码,并调用这个代码,将CLR和MAPI世界保留在单独的进程中,但支持时尚。



@Chris Fournier re。编写非托管DLL。这不会奏效,因为问题是在相同的过程中混合MAPI和托管代码


Using MAPI functions from within managed code is officially unsupported. Apparently, MAPI uses its own memory management and it crashes and burns within managed code (see here and here)

All I want to do is launch the default e-mail client with subject, body, AND one or more attachments.

So I've been looking into MAPISendDocuments and it seems to work. But I haven't been able to gather courage to actually use the function in production code.

Has anybody used this function a lot? Do you have any horror stories?

PS. No, I won't shellExecute Outlook.exe with command line arguments for attachments.

PPS. Attachment support is a requirement , so Mailto: solutions do not cut it for me.

解决方案

Have a separate helper EXE that takes command-line params (or pipe to its StandardInput) that does what is required and call that from your main app. This keeps the MAPI stuff outside of your main app's process space. OK, you're still mixing MAPI and .NET but in a very short-lived process. The assumption is that MAPI and the CLR start causing issues with longer-running processes.

We use Dmitry Streblechenko's superb Redemption Data Objects library which allows us to write such "shim" code in JScript and invoke that, which keeps the CLR and MAPI worlds in separate processes, but in a supported fashion.

@Chris Fournier re. writing an unmanaged DLL. This won't work because the issue is mixing MAPI and managed code in the same process.

这篇关于MAPI和托管代码体验?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆