我正在尝试将帐户添加到约会的 RequiredAttendees 属性中。我的代码在电子邮件、传真、信件上都能完美运行。但是在创建时约会,不添加该属性。
string[] ToArr = new string[1];
Guid To = Guid.Empty;
try
{
if (Utility.To.Contains(";"))
{
ToArr = Utility.To.Split(';');
}
else
{
ToArr[0] = Utility.To;
}
EntityCollection collToParty = new EntityCollection();
for (int i = 0; i < ToArr.Length; i++)
{
if (Guid.TryParse(ToArr[i].ToString(), out To))
{
EntityReference to = new EntityReference(Utility.Toguidentityname, To);
Entity toParty = new Entity("activityparty");
toParty.Attributes.Add("partyid", to);
collToParty.EntityName = Utility.Toguidentityname;
collToParty.Entities.Add(toParty);
}
else
{
throw new Exception("Il valore del campo della stringa " + To + " toGuid non è un GUID:" + ToArr[i].ToString());
}
}
if (entity.LogicalName.Equals("appointment"))
entity.Attributes.Add("RequiredAttendees", collToParty);
else
entity.Attributes.Add("to", collToParty);
}
catch (Exception ex)
{
LoggerObj.writeLog("Errore:" + ex.Message);
throw;
}