展望收到COMException [英] Outlook COMException

查看:256
本文介绍了展望收到COMException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

System.Runtime.InteropServices.COMException ..Your服务器管理员已限制在Microsoft.Office.Interop您可以同时打开的项目数...

System.Runtime.InteropServices.COMException ..Your server administrator has limited the number of items you can open simultaneously...

。 。Outlook._AppointmentItem.get_UserProperties()

at Microsoft.Office.Interop.Outlook._AppointmentItem.get_UserProperties()

        var calendar = outlookApplication.GetNamespace("MAPI").GetDefaultFolder(OlDefaultFolders.olFolderCalendar);

        if (calendar == null || calendar.Items == null)
        {
            return null;
        }

        var calendarItems = calendar.Items;

        if (calendarItems != null && calendarItems.Count > 0)
        {
            // Dont convert to LINQ or foreach please -> may cause Outlook memory leaks. 
            for (int counter = 1; counter <= calendarItems.Count; counter++)
            {
                var appointment = calendarItems[counter] as AppointmentItem;

                if (appointment != null)
                {
                    var userProperty = appointment.UserProperties.Find("myInformation");

                    if (userProperty != null && userProperty.Value == myValue)
                    {
                        return appointment ;
                    }
                }
            }
        }



也许其appointment.UserProperties.Find(myInformation)收到COMException原因?

Maybe its appointment.UserProperties.Find("myInformation") cause COMException?

推荐答案

我发现这个解决方案。它不是必要使用查找事业限制让我需要什么。

I have found the solution for this. It isnt necessary to use Find cause Restrict make what I need.

...
string filter = string.Format("[myInformation] = '{0}'", myInformation);
var calendarItems = calendar.Items.Restrict(filter);
...

这篇关于展望收到COMException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆