我需要在 Outlook 2007 中修改许多 MailItems。
我需要邮件在 Outlook 主网格中立即刷新——我发现的唯一方法是调用 MailItem.Save()。
foreach (var item in folder.Items)
{
var mail = item as MailItem;
if (mail != null) // process only MailItems
{
setUserProperty(mail, userPropKey, "speed test");
mail.Save(); // Save() to make the grid row redraw
if (++cnt == 10) // stop after 10 mails
break;
}
}
问题是IMAP 帐户上的 Save() 速度很慢- 每 1 个 Save() 调用 1 秒,可能是由于与服务器的通信。在 POP3 帐户上没问题。
我需要对每封电子邮件进行的修改只是更改用户属性。我在 Outlook 中定义了一个自定义视图,该视图显示具有此属性的列。
有没有办法:
- 将用户属性设置为 PST 本地,以便在 Save() 上不与服务器通信?
- 一批完成所有 Save() 调用?
我在这样的电子邮件上设置用户属性:
void setUserProperty(Outlook.MailItem item, string key, string value)
{
item.UserProperties.Add(key, Outlook.OlUserPropertyType.olText, true, Outlook.OlFormatText.olFormatTextText);
item.UserProperties[key].Value = value;
}