Im working with WPF and Im trying to create a dragndrop text box.
In this text box, I want to get the body of the letter that I drag from Outlook.
The code works, but I think I need something to "reset", the reason ActiveExplorer now shows only the last "NEW" letter, which I drag into the text box.
Example:
Drag Email 1 -> Text Box - Shows Email 1
Drag Email 2 -> Text Box - Shows Email 2
Drag email 1 -> Text box - Shows email address 2 and email address 1 will not be displayed because it already exists in ActiveExplorer and it will show email 2.
I hope you will understand my question a little.
Thanks in advance!
XAML Code:
<TextBox Name="myTextbox" AllowDrop="True" PreviewDragEnter="email_DragEnter" PreviewDrop="email_Drop" />
XAML code behind:
private void email_DragEnter(object sender, DragEventArgs e) { e.Effect = DragDropEffects.Copy; } private void email_Drop(object sender, DragEventArgs e) { Outlook.ApplicationClass oApp = new Outlook.ApplicationClass(); Outlook.Explorer oExplorer = oApp.ActiveExplorer(); Outlook.Selection oSelection = oExplorer.Selection; foreach (object item in oSelection) { Outlook.MailItem mi = (Outlook.MailItem)item; myTextbox.Text = mi.Body.ToString(); } }
c # outlook wpf drag-and-drop
jefsmi
source share