我使用以下代码来获取Outlook 2010规则。但它抛出的异常是:
"This store does not support rules. Could not complete the operation."
我正在使用控制台应用程序获取Outlook规则。
public void removeRules(MSOutlook.Application app)
{
Console.WriteLine(" in removeRules ");
string ruleName = "SvcForeRule";
try
{
// Get Rules from Session.DefaultStore object
foreach (MSOutlook.Rules rules in app.Session.DefaultStore.GetRules())
{
Console.WriteLine(" rules count : " + rules.Count);
for (int i = 1; i <= rules.Count; i++)
{
MSOutlook.Rule rule1 = rules[i];
if (rule1.Name == ruleName)
{
Console.WriteLine(" rules Name : " + rule1.Name);
rules.Remove(i);
Marshal.ReleaseComObject(rule1);
break;
}
Marshal.ReleaseComObject(rule1);
}
}
}
catch (Exception ex)
{
Console.WriteLine("Exception in remove rules : " + ex.Message);
}
}
答案 0 :(得分:1)
哪行代码会产生异常?您是否尝试调试代码?
首先,确保安装了Outlook 2010的所有最新更新和Service Pack。
然后尝试更改以下行代码:
app.Session.DefaultStore.GetRules
要
app.Session.Stores(1).GetRules
This store does not support rule - MS Outlook 2010论坛帖子描述了完全相同的问题。