Пример #1
0
 private void makeListMailIndex()
 {
     Microsoft.Office.Interop.Outlook.Items v_EmailItems = m_Inbox.Items;
     foreach (var i_Item in v_EmailItems)
     {
         var v_Email = (MailItem)i_Item;
         var v_Id = v_Email.EntryID;
         m_ListIndexMailItem.Add(v_Id, v_Email);
     }
 }
Пример #2
0
        private async Task<List<JsonReceiveEmailClassification>> getListTaskResponse()
        {
            Microsoft.Office.Interop.Outlook.Items v_EmailItems = m_Inbox.Items;

            List<JsonReceiveEmailClassification> v_ListTaskResponse = new List<JsonReceiveEmailClassification>();

            var v_EmailClassification = "http://localhost:8080/email_classification";
            var v_HtmlUtils = new HtmlUtils();
            foreach (var i_Item in v_EmailItems)
            {
                try
                {
                    var v_Email = (MailItem)i_Item;
                    var v_Id = v_Email.EntryID;
                    var v_Subject = v_Email.Subject;
                    var v_Body = v_Email.Body;
                    StringBuilder v_EmailClasssification = new StringBuilder(v_Email.Subject).Append(". ");
                    if (v_Email.BodyFormat == OlBodyFormat.olFormatHTML)
                    {
                        v_EmailClasssification.Append(v_HtmlUtils.HtmlToText(v_Body));
                    }
                    else
                    {
                        v_EmailClasssification.Append(v_Body);
                    }

                    var v_EmailToSend = v_EmailClasssification.ToString().Replace("\n", " ").Replace("\t", " ").Replace("\r", " ");
                    var v_PostJsonTask = v_EmailClassification.PostJsonAsync(new { id = v_Id, email = v_EmailToSend });
                    var v_TaskJsonResponse = await v_PostJsonTask.ReceiveJson<JsonReceiveEmailClassification>();
                    v_ListTaskResponse.Add(v_TaskJsonResponse);
                }
                catch
                {

                }

            }

            return v_ListTaskResponse;
        }
Пример #3
0
        public Microsoft.Office.Interop.Outlook.AppointmentItem findNextOccuranceOfThisMeeting(String subject, Microsoft.Office.Interop.Outlook.MAPIFolder calendar, Outlook.AppointmentItem calItem, String inviteeList)
        {
            Microsoft.Office.Interop.Outlook.Items oItems = (Microsoft.Office.Interop.Outlook.Items)calendar.Items;

            DateTime startDate = calItem.Start;

            oItems.Sort("[Start]", false);
            oItems.IncludeRecurrences = true;

            String StringToCheck = "";

            StringToCheck = "[Start] > " + "\'" + startDate.ToString().Substring(0, startDate.ToString().IndexOf(" ") + 1).Trim() + "\'"
                            + " AND [Subject] = '" + calItem.Subject.Trim() + "'";
            // StringToCheck = "[Start] > " + "\'" + startDate.AddDays(1).ToString().Substring(0, startDate.ToString().IndexOf(" ")) + "\'"
            //                            + " AND [Subject] = '" + calItem.Subject.Trim() + "'";

            Microsoft.Office.Interop.Outlook.Items restricted;

            restricted = oItems.Restrict(StringToCheck);
            restricted.Sort("[Start]", false);

            restricted.IncludeRecurrences = true;
            Microsoft.Office.Interop.Outlook.AppointmentItem oAppt = (Microsoft.Office.Interop.Outlook.AppointmentItem)restricted.GetFirst();

            if (oAppt != null) //Next occurance found
            {
                //Outlook.MailItem em=
                Outlook.MailItem em = app.CreateItem(Outlook.OlItemType.olMailItem) as Outlook.MailItem;

                em.HTMLBody = oAppt.Body;
                label_next_meeting.Visible = false;
                nextmeetingSubject.Text    = oAppt.Subject.Trim();
                nextMeetingLocation.Text   = oAppt.Location != null?oAppt.Location.Trim() : "";

                //MemoryStream stream = new MemoryStream(oAppt.RTFBody);
                nextMeetingBody.Rtf = System.Text.Encoding.ASCII.GetString(oAppt.RTFBody);
                //ASCIIEncoding.Default.GetBytes(
                //byte[] b =
                // nextMeetingBody.Rtf=stream.
                // nextMeetingBody.Html = em.HTMLBody;
                String timeTemp = oAppt.Start.ToString().Substring(oAppt.Start.ToString().IndexOf(" ") + 1);
                nextmeetingStartTime.Text = timeTemp.Substring(0, timeTemp.LastIndexOf(":")) + " " + (timeTemp.EndsWith("AM") ? "AM" : "PM");
                timeTemp = oAppt.End.ToString().Substring(oAppt.End.ToString().IndexOf(" ") + 1);
                nextmeetingEndTime.Text = timeTemp.Substring(0, timeTemp.LastIndexOf(":")) + " " + (timeTemp.EndsWith("AM") ? "AM" : "PM");
                dateTimePicker_nextMeetingDate.Checked = true;
                dateTimePicker_nextMeetingDate.Text    = oAppt.Start.ToString();
                styleInviteeList(inviteeList);

                //Load the attachment list if there are already uploaded attachment details for the next meeting
                if (oAppt.Attachments != null && oAppt.Attachments.Count > 0)
                {
                    foreach (Outlook.Attachment atchItem in oAppt.Attachments)
                    {
                        dataGridView_next_meeting_atch.Rows.Add(atchItem.FileName.Trim(), "");
                    }
                }

                //textBox_next_invitees.Text = inviteeList;
                //=Convert.ToDateTime(oAppt.Start.ToString().Substring(oAppt.Start.ToString().IndexOf(" ") + 1));
                return(oAppt);
            }
            else
            {
                label_next_meeting.Visible = true;
                nextmeetingSubject.Text    = subject;
                styleInviteeList(inviteeList);
                //textBox_next_invitees.Text = inviteeList;
                //textBox_next_invitees.textfr
                return(null);
            }
        }