请问 flowerwaiter :
可以做成Rule么?
我尝试着, 添加新的Rule
private void CreateManagerRule()
{
Outlook.ExchangeUser manager;
Outlook.Folder managerFolder;
Outlook.AddressEntry currentUser =
Application.Session.CurrentUser.AddressEntry;
if (currentUser.Type == "EX")
{
try
{
manager = currentUser.
GetExchangeUser().GetExchangeUserManager();
}
catch
{
Debug.WriteLine("Could not obtain user's manager.");
return;
}
Outlook.Rules rules;
try
{
rules = Application.Session.DefaultStore.GetRules();
//rules = Application.Session.Stores.;
}
catch
{
Debug.WriteLine("Could not obtain rules collection.");
return;
}
//if (manager != null)
if (true)
{
string displayName ="" ;
if (manager != null)
{
displayName = manager.Name;
}else{
displayName = "Test for me";
}
Outlook.Folders folders =
Application.Session.GetDefaultFolder(
Outlook.OlDefaultFolders.olFolderInbox).Folders;
try
{
managerFolder =
folders[displayName] as Outlook.Folder;
}
catch
{
managerFolder =
folders.Add(displayName, Type.Missing)
as Outlook.Folder;
}
Outlook.Rule rule = rules.Create(displayName,
Outlook.OlRuleType.olRuleReceive);
// Rule conditions
// From condition
//rule.Conditions.From.Recipients.Add(manager.PrimarySmtpAddress);
rule.Conditions.From.Recipients.Add("
xxxx@xxxx.xx");
rule.Conditions.From.Recipients.ResolveAll();
rule.Conditions.From.Enabled = true;
//rule.Conditions.HasAttachment.Class..From.Enabled = true;
// Sent only to me
rule.Conditions.ToMe.Enabled = true;
//rule.Actions..NewItemAlert;
//RuleAction = $rule.Actions.NewItemAlert
//$RuleAction.Text = "This is a demo script"
//$RuleAction.Enabled = $true
写到这里, 不知道如何把你的代码, 加到这里了
请指教, 谢谢!
// Rule exceptions
// Meeting invite or update
rule.Exceptions.MeetingInviteOrUpdate.Enabled = true;
// Rule actions
// MarkAsTask action
rule.Actions.MarkAsTask.MarkInterval =
Outlook.OlMarkInterval.olMarkToday;
rule.Actions.MarkAsTask.FlagTo = "Follow-up";
rule.Actions.MarkAsTask.Enabled = true;
// MoveToFolder action
rule.Actions.MoveToFolder.Folder = managerFolder;
rule.Actions.MoveToFolder.Enabled = true;
try
{
rules.Save(true);
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
}
}
}
再次感谢你的指教!