public void click() { try { if (this.Application.ActiveExplorer().Selection.Count > 0) { Object selObject = this.Application.ActiveExplorer().Selection[1]; if (selObject is Outlook.MailItem) { Outlook.MailItem mailItem = (selObject as Outlook.MailItem); string copyText = string.Format("To: {0}\nFrom: {1}\nDate: {2}\nSubject: {3}\nBody: {4}", mailItem.To, mailItem.Sender.Address, mailItem.ReceivedTime, mailItem.Subject, ThisAddIn.filterBody(mailItem.Body)); Clipboard.SetDataObject(copyText); } } } catch (Exception ex) { // Log errors ? } }
/// <summary> /// Copy data and put into Clipboard. /// </summary> public bool Copy() { if (IsEditing) { this.controlAdapter.EditControlCopy(); } else { this.controlAdapter.ChangeCursor(CursorStyle.Busy); try { if (BeforeCopy != null) { var evtArg = new BeforeRangeOperationEventArgs(selectionRange); BeforeCopy(this, evtArg); if (evtArg.IsCancelled) { return(false); } } #if EX_SCRIPT var scriptReturn = RaiseScriptEvent("oncopy"); if (scriptReturn != null && !ScriptRunningMachine.GetBoolValue(scriptReturn)) { return(false); } #endif // EX_SCRIPT // highlight current copy range currentCopingRange = selectionRange; #if WINFORM || WPF DataObject data = new DataObject(); data.SetData(ClipBoardDataFormatIdentify, GetPartialGrid(currentCopingRange, PartialGridCopyFlag.All, ExPartialGridCopyFlag.None, true)); string text = StringifyRange(currentCopingRange); if (!string.IsNullOrEmpty(text)) { data.SetText(text); } // set object data into clipboard Clipboard.SetDataObject(data); #endif // WINFORM || WPF if (AfterCopy != null) { AfterCopy(this, new RangeEventArgs(this.selectionRange)); } } catch (Exception ex) { this.NotifyExceptionHappen(ex); return(false); } finally { this.controlAdapter.ChangeCursor(CursorStyle.PlatformDefault); } } return(true); }
protected override void CopyContentToClipboard() { Clipboard.SetDataObject(dataObject.GetDataObject()); }