展望2013 API添加联系人到编程方式创建联系人组
问题描述:
我目前正在与该API的Outlook玩弄于2013年在C#中,是在创造一个联络小组(DataList控件)时,我遇到了一个奇怪的问题的过程。展望2013 API添加联系人到编程方式创建联系人组
我能够创建一个联络小组没关系使用下面的代码,创建后然而,似乎在接触组中没有接触。
然而,创建经检查时的组和添加触点(的过滤器必须有一个电子邮件地址),我可以看到触点被存储在它被保存之前的触头组的显示。
Outlook.DistListItem distList = Application.CreateItem(Outlook.OlItemType.olDistributionListItem) as Outlook.DistListItem;
distList.Subject = "TEST GROUP";
// grab all addresses such that primary email is not an empty string
string filter = "[Email1Address] <> ''";
// grab the table of users
Outlook.Table table = Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts).GetTable(filter, Outlook.OlTableContents.olUserItems);
// addingin email address so table must have column to represent this
table.Columns.Add("Email1Address");
while (!table.EndOfTable)
{
Outlook.Row nextRow = table.GetNextRow();
if (nextRow["Email1Address"] == null)
{
// no more addresses left to process.
break;
}
else
{
// create a recipient based upon information in our table
Outlook.Recipient recipient = Application.Session.CreateRecipient(nextRow["Email1Address"].ToString());
// ensure recipient is valid by checking our address book for resolution
recipient.Resolve();
MessageBox.Show(recipient.ToString() + "\nEOT: " + table.EndOfTable);
distList.AddMember(recipient);
}
}
// name the list?
distList.DLName = "Testing addin";
// save the list
distList.Save();
当尝试发送电子邮件到这个联络小组,我提示以下错误消息:
联络小组(一个或多个)此消息被发送到必须包含至少一个收件人。
答
我没有问题,从OutlookSpy运行以下脚本(点击脚本按钮上OutlookSpy丝带,将脚本粘贴,单击运行):
set DL = Application.Session.GetDefaultFolder(olFolderContacts).Items.Add(olDistributionListItem)
set Recip = Application.Session.CreateRecipient("[email protected]")
Recip.Resolve
DL.AddMember(Recip)
DL.DLName = "Testing addin"
DL.Save
确定Recipient.Resolve()返回true? –
是的,因为我直接从我的联系人把他们的书,我曾以为他们会正确解析,但是我查了所有条目,每一个被返回true。 – Healsgood