Reputation: 2247
I have WF application that allows to drag and drop emails from outlook and read the contents of an email. But when I drag'n'drop email, the emails that were dropped before are not cleared up and as a result I get the copies of the previous emails + current dragged email.
Example:
Drop mail_3 - drops mail_1, mail_2 and 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
}
How can I set the application, that only selected items are dragged into the WF? Thanks in advance
Upvotes: 0
Views: 45
Reputation: 49435
In the Drag event handler add the following line of code:
e.Data.GetData(“RenPrivateMessages”);
Upvotes: 1