示例#1
0
 public static void CreateToDo(XLVirtualCabinet.FileInfo file)
 {
     try
     {
         if (ToDoFolder == null)
         {
             SetToDoFolder();
         }
         Outlook.TaskItem toDo = Globals.ThisAddIn.Application.CreateItem(Outlook.OlItemType.olTaskItem) as Outlook.TaskItem;
         string           desc = file.ClientString;
         desc           = desc + " - " + file.Description;
         toDo.Subject   = desc;
         toDo.StartDate = DateTime.Now;
         toDo.DueDate   = DateTime.Now.AddDays(1);
         //toDo.Body = file.FileID;
         XLOutlook.UpdateParameter(fileIdName, file.FileID, toDo);
         toDo.Move(ToDoFolder);
         toDo.Save();
     }
     catch (Exception ex)
     {
         XLant.XLtools.LogException("CreateToDo", ex.ToString());
         MessageBox.Show("Could not add To Do", "Add To Do", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#2
0
 public static Outlook.TaskItem GetSelectedTask()
 {
     try
     {
         Outlook.Explorer explorer = Globals.ThisAddIn.Application.ActiveExplorer();
         if (explorer.Selection.Count == 1)
         {
             Object selItem = explorer.Selection[1];
             if (selItem is Outlook.TaskItem)
             {
                 Outlook.TaskItem task = (Outlook.TaskItem)selItem;
                 return(task);
             }
             else
             {
                 MessageBox.Show("This facility currently only handles tasks items");
                 return(null);
             }
         }
         else
         {
             MessageBox.Show("This facility will not handle bulk selection");
             return(null);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Unable to select e-mail");
         XLtools.LogException("GetSelectedEmail", ex.ToString());
         return(null);
     }
 }
示例#3
0
 protected override void Close()
 {
     Globals.ThisAddIn.EventTrackerForm.AddLog("Inspector_Close (TaskItem)");
     Item = null;
     GC.Collect();
     GC.WaitForPendingFinalizers();
 }
示例#4
0
        /// <summary>
        /// This method creates the tasks, assigns and generates the html content to be attached in the assigned tasks section of the MOM
        /// </summary>
        /// <returns></returns>
        private String assignTasks()
        {
            Dictionary <int, String> taskList = new Dictionary <int, string>();
            String returnHTML = "";

            foreach (DataGridViewRow dr in dataGridView_action_items.Rows)
            {
                try
                {
                    //Use the Outlook application object created in the previous form
                    Outlook.TaskItem taskObj = app.CreateItem(Outlook.OlItemType.olTaskItem) as Outlook.TaskItem;

                    taskObj.Subject = dr.Cells[0].Value.ToString();
                    taskObj.Body    = dr.Cells[0].Value.ToString();
                    taskObj.DueDate = DateTime.Parse(dr.Cells[1].Value.ToString());
                    //taskObj.Owner = dr.Cells[4].Value.ToString();
                    taskObj.Assign();
                    taskObj.Recipients.Add(dr.Cells[4].Value.ToString());
                    taskObj.ReminderSet  = true;
                    taskObj.ReminderTime = Convert.ToDateTime(taskObj.DueDate.ToShortDateString() + " " + comboBox_reminder.Text.Trim());
                    if (!dr.Cells[3].Value.ToString().Equals(""))
                    {
                        taskObj.Attachments.Add(dr.Cells[3].Value.ToString(), Outlook.OlAttachmentType.olByValue, 1, dr.Cells[3].Value.ToString());
                    }
                    taskObj.Send();

                    //Create the HTML content for the MOM
                    returnHTML += "<tr style='mso-yfti-irow:0;mso-yfti-firstrow:yes;mso-yfti-lastrow:yes'>" +
                                  "<td style='padding:.75pt .75pt .75pt .75pt'>" +
                                  "<p class=MsoNormal style='margin-top:3.0pt;margin-right:0cm;margin-bottom:3.0pt;margin-left:0cm'><b><span style='font-size:8.0pt;font-family:\"Book Antiqua\",\"serif\"'>" +
                                  "<a href=Outlook:" + taskObj.EntryID + ">" + taskObj.Subject + "</a>" +
                                  "</span></b></p>  </td>" +
                                  "<td style='padding:.75pt .75pt .75pt .75pt'>" +
                                  "<p class=MsoNormal style='margin-top:3.0pt;margin-right:0cm;margin-bottom: 3.0pt;margin-left:0cm'><span style='font-size:8.0pt;font-family:\"Book Antiqua\",\"serif\"'>" +
                                  taskObj.Owner +
                                  "</span></b></p>  </td>" +
                                  "<td style='padding:.75pt .75pt .75pt .75pt'>" +
                                  "<p class=MsoNormal style='margin-top:3.0pt;margin-right:0cm;margin-bottom: 3.0pt;margin-left:0cm'><span style='font-size:8.0pt;font-family:\"Book Antiqua\",\"serif\"'>" +
                                  taskObj.DueDate.ToShortDateString() +
                                  "</span></b></p>  </td>" +
                                  " </tr>";
                    //taskList.Add(dr.Index,taskObj.EntryID);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error Sending Task" + ex.ToString(), "Error", MessageBoxButtons.OK);
                }
            }
            return(returnHTML);

            /*Outlook.MailItem mailObj = FilterForm.app.CreateItem(Outlook.OlItemType.olMailItem) as Outlook.MailItem;
             * mailObj.To = "*****@*****.**";
             * String htmlBody=mailObj.HTMLBody;
             * foreach(KeyValuePair<int,String> kvp in taskList)
             * {
             *  mailObj.HTMLBody = "<a href=Outlook:" + kvp.Value + ">" + kvp.Key.ToString() + "</a>";
             * }*/
            //mailObj.HTMLBody += htmlBody;
            //mailObj.Send();
        }
 /// <summary>
 /// Open the task
 /// </summary>
 /// <param name="sender">Sender</param>
 /// <param name="e">EventArgs</param>
 private void lstTasks_DoubleClick(object sender, EventArgs e)
 {
     if (this.lstTasks.SelectedIndices.Count != 0)
     {
         OLTaskItem task = this.lstTasks.SelectedItems[0].Tag as OLTaskItem;
         if (task != null)
         {
             if (task.OriginalItem is Outlook.MailItem)
             {
                 Outlook.MailItem mail = task.OriginalItem as Outlook.MailItem;
                 mail.Display(true);
             }
             else if (task.OriginalItem is Outlook.ContactItem)
             {
                 Outlook.ContactItem contact = task.OriginalItem as Outlook.ContactItem;
                 contact.Display(true);
             }
             else if (task.OriginalItem is Outlook.TaskItem)
             {
                 Outlook.TaskItem t = task.OriginalItem as Outlook.TaskItem;
                 t.Display(true);
             }
             else
             {
                 // Do nothing
             }
             // At the end, synchronously "refresh" tasks in case they have changed
             this.RetrieveTasks();
         }
     }
 }
        /// <summary>
        /// Get the existing sync state for this item, if it exists and is of the appropriate
        /// type, else null.
        /// </summary>
        /// <remarks>Outlook items are not true objects and don't have a common superclass,
        /// so we have to use this rather clumsy overloading.</remarks>
        /// <param name="task">The item.</param>
        /// <returns>The appropriate sync state, or null if none.</returns>
        /// <exception cref="UnexpectedSyncStateClassException">if the sync state found is not of the expected class (shouldn't happen).</exception>
        public TaskSyncState GetSyncState(Outlook.TaskItem task)
        {
            SyncState result;

            try
            {
                result = this.byOutlookId.ContainsKey(task.EntryID) ? this.byOutlookId[task.EntryID] : null;
                CrmId crmId = result == null?task.GetCrmId() : CheckForDuplicateSyncState(result, task.GetCrmId());

                if (CrmId.IsValid(crmId))
                {
                    if (result == null && this.byCrmId.ContainsKey(crmId))
                    {
                        result = this.byCrmId[crmId];
                    }
                    else if (result != null && crmId != null && this.byCrmId.ContainsKey(crmId) == false)
                    {
                        this.byCrmId[crmId] = result;
                        result.CrmEntryId   = crmId;
                    }
                }

                if (result != null && !(result is TaskSyncState))
                {
                    throw new UnexpectedSyncStateClassException("TaskSyncState", result);
                }
            }
            catch (COMException)
            {
                // dead item passed.
                result = null;
            }

            return(result as TaskSyncState);
        }
示例#7
0
        public OutlookTask UpdateTask(OutlookTask TargetTask, Outlook.TaskItem SourceTaskItem, ICollection <OutlookCategory> categories, OutlookCategory defaultCategory)
        {
            OutlookCategory category = categories.Where(x => x.Name.Equals(SourceTaskItem.Categories)).SingleOrDefault();

            if (category == null)
            {
                category = defaultCategory;
            }

            TargetTask.EntryId       = SourceTaskItem.EntryID;
            TargetTask.TaskName      = SourceTaskItem.Subject;
            TargetTask.Body          = SourceTaskItem.Body;
            TargetTask.IsComplete    = SourceTaskItem.Complete;
            TargetTask.Owner         = SourceTaskItem.Owner;
            TargetTask.CreationTime  = SourceTaskItem.CreationTime;
            TargetTask.DateCompleted = (SourceTaskItem.DateCompleted.Year == 4501 ? (DateTime?)null : SourceTaskItem.DateCompleted);
            TargetTask.StartDate     = (SourceTaskItem.StartDate.Year == 4501 ? (DateTime?)null : SourceTaskItem.StartDate);
            TargetTask.DueDate       = (SourceTaskItem.DueDate.Year == 4501 ? (DateTime?)null : SourceTaskItem.DueDate);
            TargetTask.ActualWork    = SourceTaskItem.ActualWork;
            TargetTask.Status        = fromOutlookStatus(SourceTaskItem.Status);
            TargetTask.Priority      = SourceTaskItem.SchedulePlusPriority;
            TargetTask.Category      = category;

            return(TargetTask);
        }
 public void Save(IToDo t)
 {
     Outlook.TaskItem item = ((OutlookToDo)t).TaskItem;
     item.Assign();
     item.Save();
     sync();
 }
示例#9
0
        private void AddToTask(Microsoft.Office.Interop.Outlook.Inspector Inspector)
        {
            Outlook.TaskItem _ObjTaskItem = (Outlook.TaskItem)Inspector.CurrentItem;

            if (Inspector.CurrentItem is Outlook.TaskItem)
            {
                _ObjTaskItem = (Outlook.TaskItem)Inspector.CurrentItem;
                bool IsExists = false;

                foreach (Office.CommandBar _ObjCmd in Inspector.CommandBars)
                {
                    if (_ObjCmd.Name == toolBarTagTask)
                    {
                        IsExists = true;
                        _ObjCmd.Delete();
                    }
                }

                Office.CommandBar _ObjCommandBar = Inspector.CommandBars.Add(toolBarTagTask, Office.MsoBarPosition.msoBarBottom, false, true);
                _objTaskToolBarButton = (Office.CommandBarButton)_ObjCommandBar.Controls.Add(Office.MsoControlType.msoControlButton, 1, missing, missing, true);

                if (!IsExists)
                {
                    _objTaskToolBarButton.Caption = "My Task ToolBar Button";
                    _objTaskToolBarButton.Style   = Office.MsoButtonStyle.msoButtonIconAndCaptionBelow;
                    _objTaskToolBarButton.FaceId  = 500;
                    _objTaskToolBarButton.Click  += new Office._CommandBarButtonEvents_ClickEventHandler(_objTaskToolBarButton_Click);
                    _ObjCommandBar.Visible        = true;
                }
            }
        }
        private void CurrentExplorer_Event()
        {
            Outlook.MAPIFolder selectedFolder =
                this.Application.ActiveExplorer().CurrentFolder;


            try
            {
                if (this.Application.ActiveExplorer().Selection.Count > 0)
                {
                    selObject = this.Application.ActiveExplorer().Selection[1];


                    if (selObject is Outlook.TaskItem)
                    {
                        Outlook.TaskItem taskItem =
                            (selObject as Outlook.TaskItem);

                        ShowTaskOrShowParentTaskForm showTask = new ShowTaskOrShowParentTaskForm();
                        showTask.Show();
                    }
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 /// <summary>
 /// Allows to delete the selected task
 /// </summary>
 /// <param name="sender">Sender</param>
 /// <param name="e">EventArgs</param>
 private void mnuItemDeleteTask_Click(object sender, EventArgs e)
 {
     if (this.lstTasks.SelectedIndices.Count != 0)
     {
         OLTaskItem task = this.lstTasks.SelectedItems[0].Tag as OLTaskItem;
         if (task != null)
         {
             if (MessageBox.Show("Are you sure you want to delete this task?", "Delete task", MessageBoxButtons.YesNo) == DialogResult.Yes)
             {
                 if (task.OriginalItem is Outlook.MailItem)
                 {
                     Outlook.MailItem mail = task.OriginalItem as Outlook.MailItem;
                     mail.Delete();
                 }
                 else if (task.OriginalItem is Outlook.ContactItem)
                 {
                     Outlook.ContactItem contact = task.OriginalItem as Outlook.ContactItem;
                     contact.Delete();
                 }
                 else if (task.OriginalItem is Outlook.TaskItem)
                 {
                     Outlook.TaskItem t = task.OriginalItem as Outlook.TaskItem;
                     t.Delete();
                 }
                 else
                 {
                     // Do nothing
                 }
             }
             // At the end, synchronously "refresh" tasks in case they have changed
             this.RetrieveTasks();
         }
     }
 }
 /// <summary>
 /// Allows to mark the selected task as completed (clear task flag for regular items)
 /// </summary>
 /// <param name="sender">Sender</param>
 /// <param name="e">EventArgs</param>
 private void mnuItemMarkComplete_Click(object sender, EventArgs e)
 {
     if (this.lstTasks.SelectedIndices.Count != 0)
     {
         OLTaskItem task = this.lstTasks.SelectedItems[0].Tag as OLTaskItem;
         if (task != null && !task.Completed) // Attempting to complete an already completed task throws an exception
         {
             if (MessageBox.Show("Are you sure you want to complete this task?", "Mark task as completed/Clear task flag", MessageBoxButtons.YesNo) == DialogResult.Yes)
             {
                 if (task.OriginalItem is Outlook.MailItem)
                 {
                     Outlook.MailItem mail = task.OriginalItem as Outlook.MailItem;
                     mail.ClearTaskFlag();
                 }
                 else if (task.OriginalItem is Outlook.ContactItem)
                 {
                     Outlook.ContactItem contact = task.OriginalItem as Outlook.ContactItem;
                     contact.ClearTaskFlag();
                 }
                 else if (task.OriginalItem is Outlook.TaskItem)
                 {
                     Outlook.TaskItem t = task.OriginalItem as Outlook.TaskItem;
                     t.MarkComplete();
                 }
                 else
                 {
                     // Do nothing
                 }
             }
             // At the end, synchronously "refresh" tasks in case they have changed
             this.RetrieveTasks();
         }
     }
 }
        public void DeleteTask(OutlookTask task)
        {
            OutlookTask outlookTask = task as OutlookTask;

            Outlook.TaskItem taskitem = outlookApp.Session.GetItemFromID(outlookTask.EntryId) as Outlook.TaskItem;
            taskitem.Delete();
        }
示例#14
0
        /// <summary>
        /// TaskItemから、宛先(Recipient)のリスト取得する
        /// </summary>
        /// <param name="Item">TaskItemオブジェクト</param>
        /// <returns>List<Outlook.Recipient></returns>
        private static List <Outlook.Recipient> GetRecipientList(Outlook.TaskItem item)
        {
            Outlook.Recipients       recipients     = item.Recipients;
            List <Outlook.Recipient> recipientsList = new List <Outlook.Recipient>();

            if (IsSendTaskRequest(item))
            {
                //これから送信するTaskRequestItem
                for (int i = 1; i <= recipients.Count; i++)
                {
                    recipientsList.Add(recipients[i]);
                }
            }
            else
            {
                //受信したTaskRequestItem
                if (item.Owner == null)
                {
                    recipientsList.Add(item.Recipients[1]);
                }
                else
                {
                    Outlook.Recipient ownerRecipient = Globals.ThisAddIn.Application.Session.CreateRecipient(item.Owner);
                    recipientsList.Add(ownerRecipient);
                }
            }
            return(recipientsList);
        }
示例#15
0
        /// <summary>
        /// Метод ,который добавляет трекеры задач
        /// в календарь(если они не были добавлены).
        /// Отображает календарь.(когда все задачи добавлены)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonCalendR_Click(object sender, RibbonControlEventArgs e)
        {
            try
            {
                Outlook.MAPIFolder fldContacts = (Outlook.MAPIFolder)Globals.ThisAddIn.Application.Session.
                                                 GetDefaultFolder(Outlook.OlDefaultFolders.olFolderTasks);
                //Проверяем есть ли пользовательская папка
                //(которая сейчас текущая[текущий проект Redmine - который можно задовать в ленте] CurrentFolder ) в аутлуке
                Outlook.MAPIFolder my_currentFolder = CreateCustomCalendar();
                foreach (Outlook.MAPIFolder subFolder in fldContacts.Folders)
                {
                    CustomFolder = subFolder;
                    foreach (var task in CustomFolder.Items)
                    {
                        Outlook.TaskItem taskItem = (Outlook.TaskItem)task;


                        if (taskItem.DueDate == null)
                        {
                            taskItem.DueDate = DateTime.Today;
                        }
                        if (CheckTaskInOutlookCalendary(my_currentFolder, taskItem.Subject))
                        {
                            continue;
                        }
                    }
                }

                MessageBox.Show("Календарь импортирован");
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#16
0
        protected override ActivityExecutionStatus Execute(ActivityExecutionContext context)
        {
            // Create an Outlook Application object.
            Outlook.Application outlookApp = new Outlook.Application();
            // Create a new TaskItem.
            Outlook.TaskItem newTask = (Outlook.TaskItem)outlookApp.CreateItem(Outlook.OlItemType.olTaskItem);
            // Configure the task at hand and save it.
            newTask.Body       = "Workflow Generated Task";
            newTask.DueDate    = DateTime.Now;
            newTask.Importance = Outlook.OlImportance.olImportanceHigh;

            if (this.Parent.Parent is ParallelActivity)
            {
                newTask.Subject = (this.Parent.Parent.Parent.Activities[1] as DummyActivity).TitleProperty;
                if ((this.Parent.Parent.Parent.Activities[1] as DummyActivity).TitleProperty != "")
                {
                    MessageBox.Show("Creating Outlook Task");
                    newTask.Save();
                }
            }
            else if (this.Parent.Parent is SequentialWorkflowActivity)
            {
                newTask.Subject = (this.Parent.Parent.Activities[1] as DummyActivity).TitleProperty;
                if ((this.Parent.Parent.Activities[1] as DummyActivity).TitleProperty != "")
                {
                    MessageBox.Show("Creating Outlook Task");
                    newTask.Save();
                }
            }
            return(ActivityExecutionStatus.Closed);
        }
示例#17
0
        private void CurrentExplorer_Event()
        {
            Outlook.MAPIFolder selectedFolder =
                this.Application.ActiveExplorer().CurrentFolder;
            String expMessage = "Your current folder is "
                                + selectedFolder.Name + ".\n";
            String itemMessage = "Item is unknown.";

            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);
                        itemMessage = "The item is an e-mail message." +
                                      " The subject is " + mailItem.Subject + ".";
                        mailItem.Display(false);
                    }
                    else if (selObject is Outlook.ContactItem)
                    {
                        Outlook.ContactItem contactItem =
                            (selObject as Outlook.ContactItem);
                        itemMessage = "The item is a contact." +
                                      " The full name is " + contactItem.Subject + ".";
                        contactItem.Display(false);
                    }
                    else if (selObject is Outlook.AppointmentItem)
                    {
                        Outlook.AppointmentItem apptItem =
                            (selObject as Outlook.AppointmentItem);
                        itemMessage = "The item is an appointment." +
                                      " The subject is " + apptItem.Subject + ".";
                    }
                    else if (selObject is Outlook.TaskItem)
                    {
                        Outlook.TaskItem taskItem =
                            (selObject as Outlook.TaskItem);
                        itemMessage = "The item is a task. The body is "
                                      + taskItem.Body + ".";
                    }
                    else if (selObject is Outlook.MeetingItem)
                    {
                        Outlook.MeetingItem meetingItem =
                            (selObject as Outlook.MeetingItem);
                        itemMessage = "The item is a meeting item. " +
                                      "The subject is " + meetingItem.Subject + ".";
                    }
                }
                expMessage = expMessage + itemMessage;
            }
            catch (Exception ex)
            {
                expMessage = ex.Message;
            }
            MessageBox.Show(expMessage);
        }
示例#18
0
 /// <summary>
 /// Removed the specified user property from this item.
 /// </summary>
 /// <param name="olItem">The item from which the property should be removed.</param>
 /// <param name="name">The name of the property to remove.</param>
 public static void ClearUserProperty(this Outlook.TaskItem olItem, string name)
 {
     Outlook.UserProperty olProperty = olItem.UserProperties[name];
     if (olProperty != null)
     {
         olProperty.Delete();
     }
 }
        public void UpdateTask(OutlookTask task)
        {
            OutlookTask outlookTask = task as OutlookTask;

            Outlook.TaskItem taskitem = outlookApp.Session.GetItemFromID(outlookTask.EntryId) as Outlook.TaskItem;
            taskitem = taskAndCategoryLoader.UpdateOutlookTaskItem(taskitem, task as OutlookTask);
            taskitem.Save();
        }
示例#20
0
        protected internal FollowUpTaskItem(Outlook.TaskItem t)
        {
            if (t == null)
            {
                throw new ArgumentException("TaskItem is null");
            }

            _item = t;
        }
        /// <summary>
        /// Method is called when the Wrapper has been initialized
        /// </summary>
        protected override void Initialize()
        {
            // Get the Item of the current Inspector
            Item = (Outlook.TaskItem)Inspector.CurrentItem;

            // Register for the Item events
            Item.Open  += new Outlook.ItemEvents_10_OpenEventHandler(Item_Open);
            Item.Write += new Outlook.ItemEvents_10_WriteEventHandler(Item_Write);
        }
示例#22
0
 /// <summary>
 /// Метод, отображающий задачу для редактирования
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void buttonOpenTask_Click(object sender, EventArgs e)
 {
     if (Globals.ThisAddIn.selObject is Outlook.TaskItem)
     {
         Outlook.TaskItem taskItem =
             (Globals.ThisAddIn.selObject as Outlook.TaskItem);
         taskItem.Display();
     }
 }
示例#23
0
        public void AddTask()
        {
            Outlook.TaskItem newTaskItem = null;
            //Проверяем текущую папку CustomFolder
            if (ChekCustomFolderExists())
            {
                //Создаем задачу в этой папке.
                newTaskItem =
                    (Outlook.TaskItem)CustomFolder.Items.Add(Outlook.OlItemType.olTaskItem);

                newTaskItem.UserProperties.Add("Parent", OlUserPropertyType.olText, false, true);
                newTaskItem.UserProperties.Add("Project", OlUserPropertyType.olText, true, true);
                newTaskItem.UserProperties["Project"].Value = CustomFolder.Name;
                newTaskItem.UserProperties.Add("Parent", OlUserPropertyType.olText, false, true);
                newTaskItem.UserProperties["Parent"].Value = outlookTaskParent;


                newTaskItem.Display("True");


                if (newTaskItem.Subject != null)
                {
                    //Создаем  задачу в Redmine
                    CreateNewTaskRedmine(newTaskItem);
                    newTaskItem.Save();
                    //Добавляю в папку с текущем проектом
                    CustomFolder.Items.Add(newTaskItem);
                }
                else
                {
                    MessageBox.Show($"Отсутствует описание! {Environment.NewLine} Задача не была добавлена");
                }
            }
            else
            {
                CustomFolder = CreateCustomFolder(RedmineOutlookAddIn.Properties.Settings.Default.CurrentFolder);
                newTaskItem  =
                    (Outlook.TaskItem)CustomFolder.Items.Add(Outlook.OlItemType.olTaskItem);



                newTaskItem.Display("True");
                if (newTaskItem.Subject != null)
                {
                    //Создаем  задачу в Redmine
                    CreateNewTaskRedmine(newTaskItem);
                    newTaskItem.Save();
                    //Добавляю в папку с текущем проектом
                    CustomFolder.Items.Add(newTaskItem);
                }
                else
                {
                    MessageBox.Show($"Отсутствует описание! {Environment.NewLine} Задача не была добавлена");
                }
            }
            Marshal.ReleaseComObject(newTaskItem);
        }
        private void TasksUpdates()
        {
            Outlook.NameSpace   namespce = null;
            Outlook.Items       tasks    = null;
            Outlook.Application oApp     = new Outlook.Application();
            namespce = oApp.GetNamespace("MAPI");
            tasks    = namespce.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderTasks).Items;
            string temp    = string.Empty;
            string tmpRedm = string.Empty;
            bool   isExist = false;
            string AddedTastFromOutlook = string.Empty;

            foreach (Issue issue in manager.GetObjectList <Issue>(new NameValueCollection()))
            {
                foreach (Outlook.TaskItem task in tasks)
                {
                    if (task.Subject == issue.Subject)
                    {
                        if ((DateTime)issue.UpdatedOn > task.LastModificationTime)
                        {
                            UpdateOneTask(task, issue);
                        }
                        isExist = true;
                        continue;
                    }

                    temp += $"{task.Body}+{Environment.NewLine}";
                    bool isCompleeted = task.Complete;                    //Check if your task is compleeted in your application you could use EntryID property to identify a task
                    if (isCompleeted == true && task.Status != OlTaskStatus.olTaskComplete)
                    {
                        task.MarkComplete();
                        task.Save();
                    }

                    isExist = false;
                }
                if (isExist)
                {
                    Outlook.TaskItem task = null;

                    task           = (Outlook.TaskItem) this.Application.CreateItem(Outlook.OlItemType.olTaskItem);
                    task.Subject   = "Review site design";
                    task.StartDate = DateTime.Now;
                    task.DueDate   = DateTime.Now.AddDays(2);
                    task.Status    = Outlook.OlTaskStatus.olTaskNotStarted;
                    task.Save();
                    //newTaskItem.StartDate = (DateTime)issue.StartDate;
                    //newTaskItem.DueDate = (DateTime)issue.DueDate;
                    //AddedTastFromOutlook += $"{newTaskItem.Subject}+{Environment.NewLine}";

                    //Create a issue.
                }
            }

            MessageBox.Show("NewTAsk  " + AddedTastFromOutlook);
        }
示例#25
0
            public ProtoTask(Outlook.TaskItem oItem)
            {
                this.oItem = oItem;
                DateTime uTCDateTime = new DateTime();
                DateTime time2       = new DateTime();

                uTCDateTime = oItem.StartDate.ToUniversalTime();
                if (oItem.DueDate != null)
                {
                    time2 = oItem.DueDate.ToUniversalTime();
                }

                if (oItem.Body != null)
                {
                    body = oItem.Body.ToString();
                    var times = this.ParseTimesFromTaskBody(body);
                    if (times != null)
                    {
                        uTCDateTime = uTCDateTime.Add(times[0]);
                        time2       = time2.Add(times[1]);

                        //check max date, date must has value !
                        if (uTCDateTime.ToUniversalTime().Year < 4000)
                        {
                            dateStart = string.Format("{0:yyyy-MM-dd HH:mm:ss}", uTCDateTime.ToUniversalTime());
                        }
                        if (time2.ToUniversalTime().Year < 4000)
                        {
                            dateDue = string.Format("{0:yyyy-MM-dd HH:mm:ss}", time2.ToUniversalTime());
                        }
                    }
                    else
                    {
                        dateStart = oItem.StartDate.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss");
                        dateDue   = oItem.DueDate.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss");
                    }
                }
                else
                {
                    dateStart = oItem.StartDate.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss");
                    dateDue   = oItem.DueDate.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss");
                }

                if (!string.IsNullOrEmpty(body))
                {
                    int lastIndex = body.LastIndexOf("#<");
                    if (lastIndex >= 0)
                    {
                        description = body.Remove(lastIndex);
                    }
                    else
                    {
                        description = body;
                    }
                }
            }
示例#26
0
        private async void Button1_Click(object sender, RibbonControlEventArgs e)
        {
            var explorer       = Globals.ThisAddIn.Application.ActiveExplorer();
            var selectedFolder = explorer.CurrentFolder;
            var itemMessage    = "";

            try
            {
                if (explorer.Selection.Count > 0)
                {
                    Object selObject = explorer.Selection[1];
                    if (selObject is Outlook.MailItem)
                    {
                        Outlook.MailItem mailItem =
                            (selObject as Outlook.MailItem);
                        await Globals.ThisAddIn.FromMail(mailItem);
                    }
                    else if (selObject is Outlook.ContactItem)
                    {
                        Outlook.ContactItem contactItem =
                            (selObject as Outlook.ContactItem);
                        itemMessage = "The item is a contact." +
                                      " The full name is " + contactItem.Subject + ".";
                    }
                    else if (selObject is Outlook.AppointmentItem)
                    {
                        Outlook.AppointmentItem apptItem =
                            (selObject as Outlook.AppointmentItem);
                        itemMessage = "The item is an appointment." +
                                      " The subject is " + apptItem.Subject + ".";
                    }
                    else if (selObject is Outlook.TaskItem)
                    {
                        Outlook.TaskItem taskItem =
                            (selObject as Outlook.TaskItem);
                        itemMessage = "The item is a task. The body is "
                                      + taskItem.Body + ".";
                    }
                    else if (selObject is Outlook.MeetingItem)
                    {
                        Outlook.MeetingItem meetingItem =
                            (selObject as Outlook.MeetingItem);
                        itemMessage = "The item is a meeting item. " +
                                      "The subject is " + meetingItem.Subject + ".";
                    }
                }
                if (!string.IsNullOrEmpty(itemMessage))
                {
                    MessageBox.Show(itemMessage);
                }
            }
            catch (Exception ex) //when (!Env.Debugging)
            {
                MessageBox.Show("An error occured sending to YouTrack.\n" + ex.Message, "Email to YouTrack error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#27
0
 /// <summary>
 /// 送信者の情報(Dto)を取得する
 /// </summary>
 /// <param name="Item">Outlookアイテムオブジェクト</param>
 /// <returns>送信者の宛先情報インスタンス(送信者が取得できない場合null)</returns>
 public static RecipientInformationDto GetSenderInfomation(object Item)
 {
     if (Item is Outlook.MailItem)
     {
         Outlook.MailItem mail = (Item as Outlook.MailItem);
         return(GetSenderInformation(mail));
     }
     else if (Item is Outlook.MeetingItem)
     {
         Outlook.MeetingItem meeting = Item as Outlook.MeetingItem;
         return(GetSenderInformation(meeting));
     }
     else if (Item is Outlook.AppointmentItem)
     {
         Outlook.AppointmentItem appointment = Item as Outlook.AppointmentItem;
         return(GetSenderInformation(appointment));
     }
     else if (Item is Outlook.ReportItem)
     {
         Outlook.ReportItem report = Item as Outlook.ReportItem;
         return(GetSenderInformation(report));
     }
     else if (Item is Outlook.SharingItem)
     {
         Outlook.SharingItem sharing = Item as Outlook.SharingItem;
         return(GetSenderInformation(sharing));
     }
     else if (Item is Outlook.TaskItem)
     {
         Outlook.TaskItem task = Item as Outlook.TaskItem;
         return(GetSenderInformation(task));
     }
     else if (Item is Outlook.TaskRequestItem)
     {
         Outlook.TaskRequestItem taskRequest = Item as Outlook.TaskRequestItem;
         return(GetSenderInformation(taskRequest));
     }
     else if (Item is Outlook.TaskRequestAcceptItem)
     {
         Outlook.TaskRequestAcceptItem taskRequestAcceptItem = Item as Outlook.TaskRequestAcceptItem;
         string mailHeader = GetMailHeader(taskRequestAcceptItem.PropertyAccessor);
         return(GetSenderInformationFromMailHeader(mailHeader));
     }
     else if (Item is Outlook.TaskRequestDeclineItem)
     {
         Outlook.TaskRequestDeclineItem taskRequestDeclineItem = Item as Outlook.TaskRequestDeclineItem;
         string mailHeader = GetMailHeader(taskRequestDeclineItem.PropertyAccessor);
         return(GetSenderInformationFromMailHeader(mailHeader));
     }
     else
     {
         throw new NotSupportedException("未対応のOutook機能です。");
     }
 }
        /// <summary>
        /// The Close Method is called when the Inspector has been closed.
        /// Do your cleanup tasks here.
        /// The UI is gone, can't access it here.
        /// </summary>
        protected override void Close()
        {
            // unregister events
            Item.Write -= new Outlook.ItemEvents_10_WriteEventHandler(Item_Write);
            Item.Open  -= new Outlook.ItemEvents_10_OpenEventHandler(Item_Open);

            // required, just stting to NULL may keep a reference in memory of the Garbage Collector.
            Item = null;
            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
 //</Snippet1>
 //<Snippet2>
 void AddDependentTask_Click()
 {
     Outlook.TaskItem tempTaskItem = FindTaskBySubjectName(comboBox1.Text);
     if (tempTaskItem != null)
     {
         this.listBox1.AddItem(tempTaskItem.PercentComplete.ToString()
                               + "% Complete -- " + tempTaskItem.Subject, System.Type.Missing);
         this.olkTextBox3.Text = this.olkTextBox3.Text + "|" +
                                 tempTaskItem.Subject;
     }
 }
示例#30
0
        // Occurs before the form region is displayed.
        // Use this.OutlookItem to get a reference to the current Outlook item.
        // Use this.OutlookFormRegion to get a reference to the form region.
        private void BillableTaskRegion_FormRegionShowing(object sender, System.EventArgs e)
        {
            m_taskItem = this.OutlookItem as Outlook.TaskItem;

            EnsureProperties();
            chkBillable.Checked = m_isBillable.Value;
            UpdateEnableState();

            lstCustomer.SelectedText = m_customer.Value;
            numHours.Value = (decimal)m_hours.Value;
            txtDetails.Text = m_details.Value;
        }
示例#31
0
 private void btn_Click(object sender, EventArgs e)
 {
     if (lsv.SelectedItems.Count == 1)
     {
         Result       = lsv.SelectedItems[0].Tag as Outlook.TaskItem;
         DialogResult = System.Windows.Forms.DialogResult.OK;
         Close();
     }
     else
     {
         MessageBox.Show("Select a task for the message to be apended to",
                         "TaskFromMail", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }
示例#32
0
 private void btnNewTask_OnClick(object sender, IRibbonControl control, bool pressed)
 {
     Outlook.Application app = new Outlook.Application();
     this.task = (Outlook.TaskItem) app.CreateItem(Outlook.OlItemType.olTaskItem);
     this.task.Display();
     this.task.Write += task_Write;
 }
示例#33
0
 private void btnCreateTask_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     Outlook.Application app = new Outlook.Application();
     this.task = (Outlook.TaskItem)app.CreateItem(Outlook.OlItemType.olTaskItem);
     this.task.Display();
     this.task.Write += task_Write;
 }