1

我有一个简单的问题。

我为outllook安装了PIA Office 15.0,并在我的winform .net应用程序中提供了参考。

我只是想知道如果我在具有较低版本 Outlook(例如 Outlook 2007/2010)的机器上部署此应用程序,我的应用程序会正常工作吗?

抱歉,这是我为我的应用程序提供的 14.0 Outlook PIA 参考。和代码是

` 将 OutlookMes​​sage 调暗为 outlook.MailItem 将 AppOutlook 调暗为新的 Outlook.Application 尝试将 oApp 调暗为 Microsoft.Office.Interop.Outlook._Application oApp = 新的 Microsoft.Office.Interop.Outlook.Application

        Dim oMsg As Microsoft.Office.Interop.Outlook._MailItem
        oMsg = oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem)

        oMsg.Subject = P_Subj
        oMsg.Body = P_Body

        oMsg.To = P_To
        'oMsg.CC = sCC

        If Trim(P_AttachPath) <> "" Then
            Dim sBodyLen As Integer = Int(P_Body.Length)
            Dim oAttachs As Microsoft.Office.Interop.Outlook.Attachments = oMsg.Attachments
            Dim oAttach As Microsoft.Office.Interop.Outlook.Attachment

            oAttach = oAttachs.Add(P_AttachPath, , sBodyLen, P_AttachPath)
        End If

        oMsg.Send()
        MsgBox("Mail sent to outlook successfully. ", MsgBoxStyle.Information, "")
        oApp = Nothing
        oMsg = Nothing '

它给出了 Office 2007 的错误。

4

2 回答 2

0

I'd recommend using PIAs that correspond to the lowest version of Outlook/Office. Thus, you can be sure that you don't use methods and properties introduced in later versions. In general, if you embed interop types (read more below) it will run without issues.

Beginning with the .NET Framework 4, the common language runtime supports embedding type information for COM types directly into managed assemblies, instead of requiring the managed assemblies to obtain type information for COM types from interop assemblies. Because the embedded type information includes only the types and members that are actually used by a managed assembly, two managed assemblies might have very different views of the same COM type. Each managed assembly has a different Type object to represent its view of the COM type. The common language runtime supports type equivalence between these different views for interfaces, structures, enumerations, and delegates. You can read more about that in the Type Equivalence and Embedded Interop Types article in MSDN.

Also see Walkthrough: Embedding Types from Managed Assemblies (C# and Visual Basic).

于 2015-04-09T13:01:18.327 回答
0

我一直在使用Microsoft Office 2010:Primary Interop Assemblies Redistributable在我的几个应用程序中,我可以报告在运行 Office 2013/2010 的 Windows 8.1/8/7 上的部署是完美的。我在部署到运行 Office 2003 的 XP 机器上也取得了一些成功,但这并不能保证。2010 PIA Redistributable 可从http://www.microsoft.com/en-us/download/details.aspx?id=3508下载

于 2015-04-09T14:08:13.657 回答