How to Cast a dropped Outlook Contact Item on a Winform C#?
使用拖放的方法DragDrop
this.textBox.DragDrop += new System.Windows.Forms.DragEventHandler(this.textBox3_DragDrop);
this.textBox.DragEnter += new System.Windows.Forms.DragEventHandler(this.textBox3_DragEnter);
private void textBox_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.Link; //鼠标的样式
}
private void textBox_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetFormats()[0] == "RenPrivateSourceFolder")
{
Microsoft.Office.Interop.Outlook.Application outlook = Marshal.GetActiveObject("Outlook.Application") as Microsoft.Office.Interop.Outlook.Application;
Microsoft.Office.Interop.Outlook.MailItem contact = outlook.ActiveExplorer().Selection[1] as M