当前位置: 首页>>代码示例>>C#>>正文


C# Microsoft.Office.Interop.Outlook.Application.GetNamespace方法代码示例

本文整理汇总了C#中Microsoft.Office.Interop.Outlook.Application.GetNamespace方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.Office.Interop.Outlook.Application.GetNamespace方法的具体用法?C# Microsoft.Office.Interop.Outlook.Application.GetNamespace怎么用?C# Microsoft.Office.Interop.Outlook.Application.GetNamespace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Office.Interop.Outlook.Application的用法示例。


在下文中一共展示了Microsoft.Office.Interop.Outlook.Application.GetNamespace方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: object

        private static readonly object _lock = new object(); // Sync the processing of items in the Outbox

        public OutboxMonitor(Microsoft.Office.Interop.Outlook.Application application)
        {
            try
            {
                _application = application;
                _ns = _application.GetNamespace("MAPI");
                _outbox = _ns.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderOutbox);
                _items = _outbox.Items;
                _items.ItemAdd += Items_ItemAdd;

                SubmitNonDeferredItems();
                SyncroniseDeferredSendStore();
                CreateSubmitWorkerThreads();

				Logger.LogInfo("Secure File Transfer Outbox monitor created and configured.");
            }
            catch (Exception ex)
            {
                Dispose();

                Logger.LogError(ex);
                Logger.LogError("Failed to create OutboxMonitor. Disable DeferredSend");

                throw;
            }
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:28,代码来源:OutboxMonitor.cs

示例2: OutlookPortal

		public OutlookPortal()
		{
			oApp = new Microsoft.Office.Interop.Outlook.Application();
			oNameSpace = oApp.GetNamespace("MAPI");
			oOutboxFolder = oNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderOutbox);
			oNameSpace.Logon(null, null, false, false);
			oMailItem =	(Microsoft.Office.Interop.Outlook._MailItem)oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
			
		}
开发者ID:mind0n,项目名称:hive,代码行数:9,代码来源:OutlookPortal.cs

示例3: GetAllEvents

        /// <summary>
        /// Gets a list of all events in outlook
        /// </summary>
        public static List<CalendarEvent> GetAllEvents()
        {
            List<CalendarEvent> events = new List<CalendarEvent>();

            Microsoft.Office.Interop.Outlook.Application oApp = null;
            Microsoft.Office.Interop.Outlook.NameSpace mapiNamespace = null;
            Microsoft.Office.Interop.Outlook.MAPIFolder CalendarFolder = null;
            Microsoft.Office.Interop.Outlook.Items outlookCalendarItems = null;

            oApp = new Microsoft.Office.Interop.Outlook.Application();
            mapiNamespace = oApp.GetNamespace("MAPI");
            CalendarFolder = mapiNamespace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderCalendar); outlookCalendarItems = CalendarFolder.Items;
            outlookCalendarItems.IncludeRecurrences = true;

            CalendarEvent cEvent = null;

            foreach (Microsoft.Office.Interop.Outlook.AppointmentItem item in outlookCalendarItems)
            {
                cEvent = null;

                if (item.IsRecurring)
                {
                    Microsoft.Office.Interop.Outlook.RecurrencePattern rp = item.GetRecurrencePattern();
                    DateTime first = new DateTime(2008, 8, 31, item.Start.Hour, item.Start.Minute, 0);
                    DateTime last = new DateTime(2008, 10, 1);
                    Microsoft.Office.Interop.Outlook.AppointmentItem recur = null;

                    for (DateTime cur = first; cur <= last; cur = cur.AddDays(1))
                    {
                        try
                        {
                            recur = rp.GetOccurrence(cur);
                            cEvent = new CalendarEvent(recur.GlobalAppointmentID, recur.Start, recur.End, recur.Location, recur.Subject, recur.Body);
                        }
                        catch
                        { }
                    }
                }
                else
                {

                    cEvent = new CalendarEvent(item.GlobalAppointmentID, item.Start, item.End, item.Location, item.Subject, item.Body);
                }

                if (cEvent != null)
                    events.Add(cEvent);
            }

            return events;
        }
开发者ID:rburgstaler,项目名称:Outlook-To-Google-Calendar-Sync,代码行数:53,代码来源:CalendarManagerOutlook.cs

示例4: Calendar

        public Calendar(int Days, List<String> EMails, String path, String ID)
        {
            sendEmail = false;
            objEntryID = ID;
            _Days = Days;
            _EMails = EMails;
            EmailEvents = new List<EmailEvent>();

            // set log path from logPath constant from Main()
            LOGPATH = path;
#if Debug
            try
            {
#endif
               
                objOutlook = new Microsoft.Office.Interop.Outlook.Application();
                Microsoft.Office.Interop.Outlook.NameSpace objNS = objOutlook.GetNamespace("MAPI");


                //objEntryID = "000000005BCDA19FC3AF564C9A7D910BCCF3D24642820000";
                //String objEntryID = "00000000E6BD34CD1C0FA04DBA1773A312FE25690100E15948BC84BC624E822DC6493E0F48BE0010CCEC4D970000";
                
                objCalendar = objOutlook.Session.GetFolderFromID(objEntryID, System.Type.Missing);    
            

               
#if Debug

            }
            catch (Exception ex)
            {
                //ToDo:
                // add handling for exception accessing Outlook
                System.IO.File.AppendAllText(LOGPATH,DateTime.Now.ToString() + ": " + ex.Message + Environment.NewLine);
                return;
            }
#endif

            findEvents();
            


        }
开发者ID:pavel-visionmap,项目名称:VM-Odesk-Code,代码行数:43,代码来源:Calendar.cs

示例5: OutlookMail

        /// <summary>
        /// Constructor
        /// </summary>
        public OutlookMail()
        {
            //Return a reference to the MAPI layer
              oApp = new Microsoft.Office.Interop.Outlook.Application();
              oNameSpace= oApp.GetNamespace("MAPI");

              /***********************************************************************
              * Logs on the user
              * Profile: Set to null if using the currently logged on user, or set
              *    to an empty string ("") if you wish to use the default Outlook Profile.
              * Password: Set to null if  using the currently logged on user, or set
              *    to an empty string ("") if you wish to use the default Outlook Profile
              *    password.
              * ShowDialog: Set to True to display the Outlook Profile dialog box.
              * NewSession: Set to True to start a new session. Set to False to
              *    use the current session.
              ***********************************************************************/
              oNameSpace.Logon(null,null,true,true);

              //gets defaultfolder for my Outlook Outbox
              oSentItems = oNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderSentMail);
        }
开发者ID:manivts,项目名称:impexcubeapp,代码行数:25,代码来源:OutlookMail.cs

示例6: GetContent

        public List<outlookProperty> GetContent(DateTime DateFrom, DateTime DateTo)
        {
            string strContent="";
            string strSubject="";
            DateTime MailDate;
            //string strFrom;
            string strTo="";
            List<outlookProperty> result = new List<outlookProperty>();
            var app = new Microsoft.Office.Interop.Outlook.Application();
            var nameSpace = app.GetNamespace("MAPI");
            var inboxFolder = nameSpace.Folders["[email protected]"].Folders["Inbox"].Folders["MEC"];
            int intTopiterator = inboxFolder.Items.Count;
            var mailItems = inboxFolder.Items;
            //foreach (Microsoft.Office.Interop.Outlook.MailItem mailItem in inboxFolder.Items)
            for (int i = 1; i <= intTopiterator;i++ )
            {
                //strTo = mailItems[1];
                strSubject = mailItems[i].Subject.ToString();
                strContent = mailItems[i].Body.ToString();
                MailDate = mailItems[i].CreationTime.Date;
                //strFrom=mailItem.f
                //if (mailItem.To.ToString() != null)
                //{
                //    strTo = mailItem.To.ToString();
                //}
                //else
                //{
                //    strTo = "";
                //}

                if (MailDate >= DateFrom && MailDate <= DateTo)
                {
                    result.Add(new outlookProperty() { strSubject = strSubject, strContent = strContent, CreationDate = MailDate, strFrom = "", strTo = "" });
                }

            }
            return result;
        }
开发者ID:xneo123,项目名称:OutlookMachine,代码行数:38,代码来源:OutlookContentInput.cs

示例7: OpenOutlookMail

        public static void OpenOutlookMail(string outlookLink)
        {
            outlookLink = outlookLink.Substring(8);

            try
            {

                Microsoft.Office.Interop.Outlook.Application app;
                Microsoft.Office.Interop.Outlook._NameSpace ns;

                app = new Microsoft.Office.Interop.Outlook.Application();
                ns = app.GetNamespace("MAPI");
                ns.Logon(null, null, false, false);

                Microsoft.Office.Interop.Outlook.MailItem mailItem = (Microsoft.Office.Interop.Outlook.MailItem)
                    ns.GetItemFromID(outlookLink);
                mailItem.Display();
            }
            catch (Exception ex)
            {

            }
        }
开发者ID:pisceanfoot,项目名称:outlooklink,代码行数:23,代码来源:OutlookTool.cs

示例8: GetApplicationObject

        private static Microsoft.Office.Interop.Outlook.Application GetApplicationObject()
        {
            Microsoft.Office.Interop.Outlook.Application application = null;

            // Check whether there is an Outlook process running.
            if (Process.GetProcessesByName("OUTLOOK").Count() > 0)
            {

                // If so, use the GetActiveObject method to obtain the process and cast it to an Application object.
                application = Marshal.GetActiveObject("Outlook.Application") as Microsoft.Office.Interop.Outlook.Application;
            }
            else
            {

                // If not, create a new instance of Outlook and log on to the default profile.
                application = new Microsoft.Office.Interop.Outlook.Application();
                Microsoft.Office.Interop.Outlook.NameSpace nameSpace = application.GetNamespace("MAPI");
                nameSpace.Logon("yahara\test", "test1234", System.Reflection.Missing.Value, System.Reflection.Missing.Value);
                //nameSpace = null;
            }

            // Return the Outlook Application object.
            return application;
        }
开发者ID:atul898,项目名称:standup,代码行数:24,代码来源:YaharaEmployeeStatusService.cs

示例9: DoWork

        internal static Status DoWork(DateTime date, bool reallyDoWork = false)
        {
            try
            {

                if (reallyDoWork == false) //avoid contacting outlook server in this case
                {
                    var s = (from l in ListStatus
                             where l.Date == date.DateTimeToString()
                             select l).FirstOrDefault();

                    if (s != null)
                    {
                        return s;
                    }
                    else
                    {
                        return new Status(date);
                    }
                }

                lock (_doOutlookWorkSync)
                {
                    Microsoft.Office.Interop.Outlook.Application objApp = new Microsoft.Office.Interop.Outlook.Application();
                    Microsoft.Office.Interop.Outlook.NameSpace objNsp = objApp.GetNamespace("MAPI");
                    //objNsp.Logon("yahara\test", "test1234", false, true);
                    //Microsoft.Office.Interop.Outlook.Application objApp = GetApplicationObject();
                    //Microsoft.Office.Interop.Outlook.NameSpace objNsp = objApp.GetNamespace("MAPI");

                    Status s1 = null;
                    Status s2 = null;

                    Status final = null;

                    //mail
                    Microsoft.Office.Interop.Outlook.MAPIFolder objMAPIFolder = objNsp.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);

                    // Set recepient
                    Microsoft.Office.Interop.Outlook.Recipient oRecip = (Microsoft.Office.Interop.Outlook.Recipient)objNsp.CreateRecipient("[email protected]");

                    // Get calendar folder
                    Microsoft.Office.Interop.Outlook.MAPIFolder calendarFolder = objNsp.GetSharedDefaultFolder(oRecip, Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderCalendar);

                    if (ListStatus == null || ListStatus.Count == 0) // first call
                    {
                        ListStatus = new List<Status>(NumberOfPastDaysToCache + NumberOfFutureDaysToCache);

                        for (int i = -1 * NumberOfFutureDaysToCache; i < NumberOfPastDaysToCache + NumberOfFutureDaysToCache; i++)
                        {
                            DateTime specificDate = date.AddDays(-1 * i);
                            Debug.WriteLine("i=" + i.ToString() + " & specificDate=" + specificDate.DateTimeToString());
                            try
                            {
                                s1 = DownloadStatusForDate(specificDate, objMAPIFolder);
                                s2 = DownloadMeetingsForDate(specificDate, calendarFolder);
                                final = new Status(s1.Date.StringToDateTime());
                                if (s1 != null && s1.ListOfItems != null && s1.ListOfItems.Count > 0)
                                    final.ListOfItems.AddRange(s1.ListOfItems);
                                if (s2 != null && s2.ListOfItems != null && s2.ListOfItems.Count > 0)
                                    final.ListOfItems.AddRange(s2.ListOfItems);
                                ListStatus.Add(final);
                            }
                            catch
                            {
                                ListStatus.Add(new Status(specificDate));
                                ;//swallow and move on
                            }
                        }
                    }
                    else
                    {
                        try
                        {
                            s1 = DownloadStatusForDate(DateTime.Today, objMAPIFolder);
                            s2 = DownloadMeetingsForDate(DateTime.Today, calendarFolder);
                            final = new Status(s1.Date.StringToDateTime());
                            if (s1 != null && s1.ListOfItems != null && s1.ListOfItems.Count > 0)
                                final.ListOfItems.AddRange(s1.ListOfItems);
                            if (s2 != null && s2.ListOfItems != null && s2.ListOfItems.Count > 0)
                                final.ListOfItems.AddRange(s2.ListOfItems);

                            //find and remove stale entry
                            var s = (from l in ListStatus
                                     where l.Date == DateTime.Today.DateTimeToString()
                                     select l).FirstOrDefault();
                            if (s != null)
                                ListStatus.Remove(s);

                            //add fresh entry
                            ListStatus.Add(final);
                        }
                        catch
                        {
                            ;//swallow and move on
                        }
                    }

                    if (calendarFolder != null)
                    {
                        System.Runtime.InteropServices.Marshal.FinalReleaseComObject(calendarFolder);
//.........这里部分代码省略.........
开发者ID:atul898,项目名称:standup,代码行数:101,代码来源:YaharaEmployeeStatusService.cs

示例10: read

        public void read()
        {
            Microsoft.Office.Interop.Outlook.Application outlook = new Microsoft.Office.Interop.Outlook.Application();
            Microsoft.Office.Interop.Outlook.NameSpace ns = outlook.GetNamespace("Mapi");
            object _missing = Type.Missing;
            ns.Logon(_missing, _missing, false, true);
            Microsoft.Office.Interop.Outlook.MAPIFolder inbox = ns.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
            string foldername = inbox.Name;
            int iMailCount = inbox.Items.Count;
            TraceService("Inside read method");

            for(int iCount =1 ;iCount <= iMailCount;iCount++)
            {
                Object mail1 = inbox.Items[iCount];
                if (((mail1 as Microsoft.Office.Interop.Outlook.MailItem) != null) && ((mail1 as Microsoft.Office.Interop.Outlook.MailItem).UnRead == true))
                {
                    TraceService("Inside unread mail");
                    Microsoft.Office.Interop.Outlook.MailItem mail = (Microsoft.Office.Interop.Outlook.MailItem)inbox.Items[iCount];
                    SqlConnection con;
                    string connection = @"server=CSM-DEV\SQL2008;database=TerexBest;uid=sa;[email protected]";
                    TraceService("Connection with database done1");
                    con = new SqlConnection(connection);
                    SqlCommand cmd;
                    cmd = new SqlCommand();
                    con.Open();

                    cmd.Connection = con;
                    TraceService("Connection assigned to sql command");

                    string subject = mail.Subject.ToString();
                    TraceService("mail subject written"+subject);
                    string body = mail.Body.ToString();
                    cmd.Parameters.Add("@subject", SqlDbType.NVarChar).Value = subject;

                    TraceService(subject); //writing subject

                    cmd.Parameters.Add("@body", SqlDbType.NVarChar).Value = body;

                    TraceService(body); //writing subject

                    cmd.Parameters.Add("@recievedtime", SqlDbType.DateTime).Value = mail.ReceivedTime;

                    TraceService(mail.ReceivedTime.ToString()); //writing subject

                    cmd.Parameters.Add("@mailfrom", SqlDbType.NVarChar).Value = mail.SenderEmailAddress;

                    TraceService(mail.SenderEmailAddress); //writing subject
                    TraceService("Before Inventory saved");

                    cmd.CommandText = "insert into storemail(subject,body,createddatetime,mailfrom,isActive) values(@subject,@body,@recievedtime,@mailfrom,1)";
                    TraceService("Inventory saved");
                    try
                    {
                        cmd.ExecuteNonQuery();
                        mail.Delete();
                        iMailCount = iMailCount - 1;
                    }
                    catch (SqlException ex)
                    {
                        ex.ToString();
                    }
                        con.Close();
                        cmd.Dispose();
                        con.Dispose();

               }
            }

            GC.Collect();
            inbox = null;
            ns = null;
            outlook = null;
        }
开发者ID:progressiveinfotech,项目名称:PRO_FY13_40_Helpdesk-Support-and-Customization_EIHAutoMail,代码行数:73,代码来源:Service1.cs


注:本文中的Microsoft.Office.Interop.Outlook.Application.GetNamespace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。