static void Main(string[] args)
        {
            Outlook.Application oApp = new Outlook.Application();
            Outlook.NameSpace   oNS  = oApp.GetNamespace("mapi");
            oNS.Logon("appsystemacc", "App@12345", false, false);

            // THE FOLDER YOU WISH TO FIND
            Outlook.MAPIFolder MySomeValueFolder = null;
            // USE THIS TO INDICATE IF FOUND
            bool IsFound = false;

            Microsoft.Office.Interop.Outlook._Folders   oFolders;
            Microsoft.Office.Interop.Outlook.MAPIFolder oPublicFolder =
                oNS.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox).Parent;
            // Folders at Inbox level
            oFolders = oPublicFolder.Folders;
            foreach (Microsoft.Office.Interop.Outlook.MAPIFolder Folder in oFolders)
            {
                // OPTIONAL:
                // if(Folder.Name == "somevalue") { ... }
                if (Folder.EntryID == "someValue")
                {
                    Console.Write(Folder.Name + " " + Folder.StoreID);
                    MySomeValueFolder = Folder;
                    IsFound           = true;
                }
            }

            if (IsFound)
            {
                // now do with MySomeValueFolder whatever you want
            }

            Console.ReadLine();
        }
예제 #2
0
        public MOM_Form(String calendarEntryId, Microsoft.Office.Interop.Outlook.MAPIFolder calendar, Microsoft.Office.Interop.Outlook._NameSpace ns, String inviteeList, Dictionary <String, String> mapDict, Microsoft.Office.Interop.Outlook.Application appl)
        {
            InitializeComponent();
            panel1.Height = 30;
            panel_next_meeting_atch1.Height = 25;
            btnMenuGroup1.Image             = MOMOutlookAddIn.Properties.Resources.down;
            //This method will initialize the button toolbar for the text editor
            PredefinedButtonSets.SetupDefaultButtons(this.meetingNotes);
            //PredefinedButtonSets.SetupDefaultButtons(this.nextMeetingBody);
            //meetingNotes.ShowSelectionMargin = true;
            if (mapDict != null)
            {
                emailNameMappingDict = mapDict;
            }
            else
            {
                emailNameMappingDict = new Dictionary <string, string>();
            }
            app = appl;
            populateTimeCombo();
            button_Add_Action.Enabled = false;
            Outlook.AppointmentItem calItem = (Outlook.AppointmentItem)ns.GetItemFromID(calendarEntryId, calendar.StoreID);

            if (calItem != null)
            {
                meetingname.Text = calItem.Subject.Trim();
                meetingDate.Text = calItem.Start.ToString().Substring(0, calItem.Start.ToString().IndexOf(" "));
                starttime.Text   = calItem.Start.ToString().Substring(calItem.Start.ToString().IndexOf(" ") + 1);
                endtime.Text     = calItem.End.ToString().Substring(calItem.End.ToString().IndexOf(" ") + 1);
                location.Text    = calItem.Location != null?calItem.Location.Trim() : "";

                minutestaken.Text = System.DirectoryServices.AccountManagement.UserPrincipal.Current.DisplayName;
                chair.Text        = calItem.Organizer.Trim();
                inviteeListString = inviteeList;
                nextMeetingItem   = findNextOccuranceOfThisMeeting(meetingname.Text, calendar, calItem, inviteeList);
                populateAssignedToListBoxAndAttendeeCheckBox();
            }
            //minutestaken.Text=calItem.c
        }
예제 #3
0
        static void mailtest()
        {
            string folderName    = ConfigurationManager.AppSettings["olfoldername"];
            string strSearchText = ConfigurationManager.AppSettings["olsubname"];
            string dstfldrpath   = ConfigurationManager.AppSettings["dstpath"];
            string emaillist     = ConfigurationManager.AppSettings["EmailList"];

            globalvar.EmailList = emaillist;
            //************************ Declare OutLook Interop Variables ****************************************
            Outlook.Application oApp = new Outlook.Application();
            Outlook.NameSpace   oNS  = oApp.GetNamespace("MAPI");
            Microsoft.Office.Interop.Outlook.MAPIFolder reqfolder = null;
            Microsoft.Office.Interop.Outlook._Folders   oFolders;
            Microsoft.Office.Interop.Outlook.MAPIFolder oPublicFolder =
                oNS.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox).Parent;
            //Folders at Inbox level
            oFolders = oPublicFolder.Folders;
            foreach (Microsoft.Office.Interop.Outlook.MAPIFolder Folder in oFolders)
            {
                string foldername = Folder.Name;
                if (foldername.ToLower() == folderName.ToLower())
                {
                    reqfolder = Folder;
                    break;
                }
            }

            string msgbody = null;

            foreach (Outlook.MailItem ind_items in reqfolder.Items)
            {
                if (ind_items.Subject.Contains(strSearchText))
                {
                    msgbody = msgbody + ind_items.Body;
                }
                else
                {
                    Console.WriteLine("Message is skipped as Subject line was not matching");
                }
            }

            Console.WriteLine(msgbody);
            string pattn = "\".*.exe\"";

            Console.WriteLine("Parsed String from [ " + folderName + "  ] folder  is: " + regexpmatch(msgbody, pattn));

            string[] srcpaths = regexpmatch(msgbody, pattn).Split(new char[] { ';' });
            int      cnt      = 1;

            foreach (string indpath in srcpaths)
            {
                Console.WriteLine("Path " + cnt + " is " + indpath);
                cnt++;
            }
            Console.WriteLine("The path parsed from latest email obtained is:  " + srcpaths[srcpaths.Length - 2]);

            string[] cutstrings = getLastCutstrings(srcpaths[srcpaths.Length - 2]).Split(new char[] { ';' });

            Console.WriteLine("Source path from Email parsed: " + cutstrings[0]);
            Console.WriteLine("File Name from Email parsed: " + cutstrings[1]);

            Console.WriteLine("Src " + cutstrings[0]);
            Console.WriteLine("Dst " + dstfldrpath);
            Console.WriteLine("file " + cutstrings[1]);
            //  Console.ReadLine();
            dorobocopy(cutstrings[0], dstfldrpath, cutstrings[1]);
            sendemail(globalvar.EmailList, dstfldrpath + "\\" + cutstrings[1]);
        }
예제 #4
0
  private void loadMembers()
  {
      m_Inbox = Globals.ThisAddIn.Application.ActiveExplorer().Session.
 GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
  }
예제 #5
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);
            }
        }