如何创建Microsoft Outlook Coded UI Extension插件

时间:2012-07-06 06:39:20

标签: .net coded-ui-tests

我有一个Autonomy / IManage(文档管理系统)应用程序,它集成在Microsoft Outlook中,它将结果作为标题,文档版本,作者等列中的不同邮件项目部分提供给你。我需要自动化此应用程序使用编码的用户界面,但我无法选择结果,就像收件箱结果在另一个邮件项目部分。 我在网上搜索除了插入之外的其他选择来捕获这些结果,但是除了编码的ui扩展插件之外无法找到它。

有没有办法从outlook中捕获这些项目?或者如果我需要一个编码的ui扩展插件,有人可以提供已经有插件的人。

1 个答案:

答案 0 :(得分:2)

我通过OOM做到了。我使用发件人的电子邮件地址和电子邮件主题来查找邮件。代码如下。

private string SelectMail(string addressTag, string subject)

{
    Outlook.Application app = new Outlook.Application();
    Outlook.Explorer explorer = app.ActiveExplorer();
    explorer.ClearSelection();

    string senderEmail = Utils.Setting.Get(addressTag);

    IEnumerable<Outlook.MailItem> selectedMails = from Outlook.MailItem mailItem in explorer.CurrentFolder.Items
                                                  where mailItem.SenderEmailAddress == senderEmail && mailItem.Subject == subject
                                                  select mailItem;
    Outlook.MailItem mail = selectedMails.FirstOrDefault<Outlook.MailItem>();

    explorer.AddToSelection(mail);

    return mail.Subject;
}