【问题标题】:Outlook not installing most recent Addin versionOutlook 未安装最新的插件版本
【发布时间】:2017-01-04 17:37:45
【问题描述】:

我刚刚开始为 Outlook 开发插件。当我第一次运行插件时 Outlook 打开,插件的安装窗口显示,它可以正常工作。例如,我的测试应用程序将所有主题为“USED CARS”的电子邮件移动到回收站。

我将过滤器更改为“测试”,在 VS2010 中运行调试器并给自己发送了一封主题为“测试”的电子邮件。由于某种原因,它不起作用。但是,即使我更改了代码,它仍在移动主题为“二手车”的电子邮件。

我已经尝试从 Outlook 中删除插件,但没有帮助。

下面是当前代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Outlook = Microsoft.Office.Interop.Outlook;
using Office = Microsoft.Office.Core;

namespace test3
{
public partial class ThisAddIn
{

    Outlook.NameSpace outlookNameSpace;
    Outlook.MAPIFolder inbox;
    Outlook.Items items;

    private void ThisAddIn_Startup(object sender, System.EventArgs e)
    {
        outlookNameSpace = this.Application.GetNamespace("MAPI");
        inbox = outlookNameSpace.GetDefaultFolder(
                Microsoft.Office.Interop.Outlook.
                OlDefaultFolders.olFolderInbox);

        items = inbox.Items;
        items.ItemAdd +=
            new Outlook.ItemsEvents_ItemAddEventHandler(items_ItemAdd);
    }

    void items_ItemAdd(object Item)
    {
        string filter = "test";
        Outlook.MailItem mail = (Outlook.MailItem)Item;
        if (Item != null)
        {
            if (mail.MessageClass == "IPM.Note" &&
                       mail.Subject.ToUpper().Contains(filter.ToUpper()))
            {
                mail.Move(outlookNameSpace.GetDefaultFolder(
                    Microsoft.Office.Interop.Outlook.
                    OlDefaultFolders.olFolderDeletedItems));
            }
        }

    }
    private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
    {
    }

    #region VSTO generated code

    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InternalStartup()
    {
        this.Startup += new System.EventHandler(ThisAddIn_Startup);
        this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
    }

    #endregion
}
}

原代码可以在here找到。

目前我唯一的解决方案是在每次更改代码时创建一个具有不同名称的新项目。

感谢您的帮助!

更新

作为工作升级的一部分,我购买了一台新 PC 以及最新版本的 Visual Studio 和 Outlook。现在这不再是问题了。

【问题讨论】:

    标签: c# email outlook


    【解决方案1】:

    您的问题可能与 Visual Studio 的版本有关。我刚刚在 VS2013 中尝试过这个,没有任何问题。您的代码对我来说似乎很好。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-12-16
      • 1970-01-01
      • 2014-12-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多