【发布时间】: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