从 Office.Interop.Outlook 迁移

思约翰

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

搜索 Exchange WebServices 但没有找到等效项。

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

    Public Function OpenOutlookSendWithAttachment(ByVal Subject As String, ByVal Body As String, ByVal FileName As String) As Boolean
        Dim bSuccess As Boolean = True
        Dim OutlookApplication As Microsoft.Office.Interop.Outlook.Application
        Dim OutlookMailItem As Microsoft.Office.Interop.Outlook.MailItem

        Try
            OutlookApplication = New Microsoft.Office.Interop.Outlook.Application
            Try
                If OutlookApplication.Session.Offline Then OutlookApplication.Session.Logon("", "", True, True)
            Catch ex As Exception
            End Try
            OutlookMailItem = OutlookApplication.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)
            OutlookMailItem.Subject = Subject
            OutlookMailItem.Body = Body & vbNewLine
            OutlookMailItem.Attachments.Add(FileName)
            OutlookMailItem.Display(True)
        Catch ex As Exception
            bSuccess = False
        Finally
            OutlookMailItem = Nothing
            OutlookApplication = Nothing
        End Try

        Return bSuccess
    End Function

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

德米特里·斯特雷布列琴科

您可以使用mailto链接(不支持附件)或创建 MSG(二进制)或 EML(MIME 文本)文件:Outlook 很乐意打开并显示它。

在后一种情况下(.EML 文件),不要忘记添加"X-Unsent: 1"MIME 标头以强制 Outlook 将邮件视为未发送并显示“发送”按钮。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

性能-Microsoft.Office.Interop.Outlook.Items.Find()与LINQ

VS2017中缺少Microsoft.Office.Interop.Outlook

Office.Interop.Outlook.MailItem 如何获取本地文件的路径

使用Microsoft.Office.Interop.Outlook连接到Outlook的稳定性C#表单

如何使用Microsoft.Office.Interop.Outlook库通过C#读取.eml文件?

无法将“System.String”类型的对象转换为“Microsoft.Office.Interop.Outlook.Store”

使用Microsoft.Office.Interop.Outlook查找所有可用会议室

InvalidCastException-无法转换类型为“ Microsoft.Office.Interop.Outlook.ApplicationClass”的COM对象

从我的 WPF 项目设置发件人帐户到我的 Microsoft.Office.Interop.Outlook._MailItem

终止的Office 365订阅可以迁移到Outlook.com上的日历和联系人吗?

将自定义域Outlook.com帐户迁移到Office 365商业

Office 2007的Microsoft.Office.Interop.Excel

Outlook Interop MailItem与F#

Office 365-组(从Office 2010迁移)

如何迁移Microsoft Office设置?

Microsoft.Office.Interop.Word OMath

.NET Core 3.0和MS Office Interop

Office Interop 更改项目之间的返回类型

Microsoft.Office.Interop.Excel的阅读范围

在BluePrism中引用Office Interop对象

VSTO Office Interop:在运行时处理Office XML

Outlook Interop 删除约会匹配模式

NET Core 3.0中的Outlook Interop?

如何使用 Outlook Interop 删除 UserProperty?

Office Outlook,禁用 GIF 动画

C#-Microsoft.Office.Interop.Excel.Sheets到Microsoft.Office.Interop.Excel.Worksheet []

Windows Azure的Office 365迁移实践

从SBS 2008(Exchange)迁移到Office 365

在VBScript中使用Microsoft.Office.Interop.Word枚举常量