从C#启动电子邮件应用程序(MAPI)(附件)

编程入门 行业动态 更新时间:2024-10-27 23:18:49
本文介绍了从C#启动电子邮件应用程序(MAPI)(附件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在过去,我已经使用MAPISendMail则来自同一个文件附件C ++应用程序推出的Outlook(或任何所需的MAPI电子邮件应用是)。 (类似于说Microsoft Word中的发送电子邮件功能)。

In the past I have used MAPISendMail to launch Outlook (or whatever the desired MAPI email application was) from a C++ application with a file attachment. (Similar to say Microsoft Word's Send Email functionality).

我需要做的从C#应用程序相媲美,并具有在XP,Vista中,Server 2008中运行时,它的工作(和Windows 7我想)。

I need to do the equivalent from a C# application and to have it work when running on XP, Vista, Server 2008 (and Windows 7 I suppose).

MAPISendMail则是在Vista / 2008,因为它总是返回MAPI_ E_FAILURE当Outlook正在运行,并在托管代码中不支持MAPI不走。 检查此修复程序后,即使: support.microsoft/kb/939718 我不能让它可靠地工作。

MAPISendMail is a no go under Vista/2008 as it always returns MAPI_ E_FAILURE when Outlook is running and MAPI is not supported in managed code. Even after checking this fix: support.microsoft/kb/939718 I can't get it to reliably work.

我知道,微软Word和放大器; ADOBE READER 9可以同时启动Outlook与Vista下的附件。

AC#兼容的解决方案将是首选,但我很乐意与任何该作品(没有使用MAPI)。我似乎无法查找当前的解决方案是什么。对堆栈溢出的现有答案似乎都不要么支付本

编辑:的

我知道MAPI和C#不在一起工作,所以我就以一个C / C ++的解决方案,在Vista中工作和Server 2008时,不会以管理员身份运行。请参阅Adobe阅读器9和; Microsoft Word作为这项工作的例子。

I am aware MAPI and C# do not work together, so I will take a C/C++ solution that works in Vista and Server 2008 when NOT running as administrator. See Adobe Reader 9 & Microsoft Word as examples that work.

推荐答案

在工作中,我们已经成功地做​​到了这一点使用VSTO。

At work we have successfully done this using VSTO.

下面是我们对VISTA与Outlook 2007中运行某些线路的一个片段:(代码是VB)

Here is a snippet of some lines we have running on VISTA with Outlook 2007: (the code is in VB).

请注意做某些事情的前景对象时使用是安全锁定。 (为解决,身体和其他属性标记为安全风险)。我们使用一个第三方组件(赎回)去解决这个安全性。如果你不使用某种形式的安全管理器,Outlook将给予一点点弹出的东西外面正试图访问它,你可以给它在一段时间内获得。

Note that the usage is security locked when doing certain things to the outlook object. (to address, body and other properties marked as security risks). We use a 3rd party component (Redemption) to go around this security. If you dont use a security manager of some sort, outlook will give a little popup that something outside is trying to access it and you can give it access in a period of time.

Outlook界面的导入。

The import of the Outlook interface.

Imports Outlook = Microsoft.Office.Interop.Outlook

这例子是给你一些指导,而不是一个完整的工作的例子。

This example is to give you some direction, not a full working example.

dim MailItem As Microsoft.Office.Interop.Outlook.MailItem ' Lets initialize outlook object ' MailItem = OutlookSession.Application.CreateItem(Outlook.OlItemType.olMailItem) MailItem.To = mailto MailItem.Subject = communication.Subject MailItem.BodyFormat = Outlook.OlBodyFormat.olFormatHTML MailItem.HTMLBody = htmlBody MailItem.Attachments.Add(filename, Outlook.OlAttachmentType.olByValue) ' If True is supplied to Display it will act as modal and is executed sequential. ' SafeMail.Display(True)

在上面的例子中的OutlookSession从该来属性:

The OutlookSession in the above example is coming from this Property:

Public ReadOnly Property OutlookSession() As Outlook.NameSpace Get If Not OutlookApplication Is Nothing Then Return OutlookApplication.GetNamespace ("MAPI") Else Return Nothing End If End Get End Property

你可以它使用MAPI内此看到的。

As you can see it is using MAPI inside for this.

好运气吧。

更多推荐

从C#启动电子邮件应用程序(MAPI)(附件)

本文发布于:2023-11-02 13:11:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1552494.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   附件   电子邮件   MAPI

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!