【问题标题】:Drag'n'drop outlook mail to wf is working incorrectly将 Outlook 邮件拖放到 wf 工作不正常
【发布时间】:2015-05-04 04:45:44
【问题描述】:

我有 WF 应用程序,它允许从 Outlook 拖放电子邮件并阅读电子邮件的内容。但是当我拖放电子邮件时,之前丢弃的电子邮件不会被清除,因此我得到了以前电子邮件的副本+当前拖动的电子邮件。

例子:

  • 删除 mail_1 - 确定
  • 丢弃 mail_2 - 丢弃 mail_1 和 mail_2
  • 丢弃 mail_3 - 丢弃 mail_1、mail_2 和 mail_3

      private void listBox1_DragDrop(object sender, DragEventArgs e)
            {
                Explorer oExplorer = _Outlook.ActiveExplorer();
                Selection oSelection = oExplorer.Selection;
                foreach (object item in oSelection)
                {
                    MailItem mi = (MailItem)item;
                    StringBuilder mailHeader = new StringBuilder();
                    mailHeader.Append(count + ". "+mi.SenderName +" | " + mi.Subject);
                    mailList.Items.Add(mailHeader.ToString());
                    count++;
                    oExplorer.RemoveFromSelection(item); //unfortunatelly this not clearing previous emails.
    
                }
                //oExplorer.ClearSelection() is not clearing either
            }
    

如何设置应用程序,只将选定的项目拖到 WF 中?提前致谢

【问题讨论】:

    标签: winforms drag-and-drop outlook office-interop


    【解决方案1】:

    在 Drag 事件处理程序中添加以下代码行:

     e.Data.GetData(“RenPrivateMessages”);
    

    【讨论】:

    • 您能否详细说明一下,为什么会这样?或者一些我可以阅读这个主题的来源。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-01-27
    • 2010-09-06
    • 1970-01-01
    • 1970-01-01
    • 2021-10-31
    • 2013-05-28
    • 1970-01-01
    相关资源
    最近更新 更多