gpt4 book ai didi

c# - 展望COMException

转载 作者:太空狗 更新时间:2023-10-30 00:54:20 25 4
gpt4 key购买 nike

System.Runtime.InteropServices.COMException ..您的服务器管理员限制了您可以同时打开的项目数...

在 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?

最佳答案

完成 Outlook Mailitem 后关闭它然后释放它

For Each item As Outlook.MailItem In oFolder.Items
'<process item code>

'Close the item
'SaveMode Values
'olDiscard = 1
'olPromptForSave = 2
'olSave = 0
item.Close(1)

'Release item
Marshal.ReleaseComObject(item)
Next

关于c# - 展望COMException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13271829/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com