public void CreateTaskClicked(IRibbonControl control) { var selection = _application.ActiveExplorer().Selection.Cast <MailItem>(); var mailItem = selection.ElementAt(0); var folder = mailItem.Parent as Folder; // Create guid for mail here string guid = GetNewOrExistingGuid(mailItem); TaskItem taskItem = (TaskItem)_application.CreateItem(OlItemType.olTaskItem); taskItem.Subject = mailItem.Subject; taskItem.Body = Utils.RemoveHyperLinks(mailItem.Body) + "\n\n" + Utils.BuildMailItemLink(mailItem, folder, guid); taskItem.Display(); }
private void LinkMailToTask(TaskItem taskItem) { if (taskItem != null) { var selection = _application.ActiveExplorer().Selection.Cast <MailItem>(); var mailItem = selection.ElementAt(0); var folder = mailItem.Parent as Folder; // Create guid for mail here string guid = GetNewOrExistingGuid(mailItem); // Append mail link to task StringBuilder stringBuilder = new StringBuilder(taskItem.Body); stringBuilder.AppendLine(); stringBuilder.AppendLine(Utils.BuildMailItemLink(mailItem, folder, guid)); taskItem.Body = stringBuilder.ToString(); taskItem.Display(); } }