Re: ¿Is it possible to create a contact in Exchange 2007 with webdav operations?
- From: "shades_80 via WinServerKB.com" <u46887@uwe>
- Date: Mon, 27 Oct 2008 19:06:19 GMT
Thanks by your help Glen.
After I pasted your code some bugs appeared which I could correct except the
one I mention in the following lines:
List<DLEntry> DLEntries = new List<DLEntry>();
Error 1. The type or namespace name 'DLEntry' could not be found (are you
missing a using directive or an assembly reference?)
I understood that the bug appeared because C# wasn't able to recognize
DLEntry as a valid data type. Do you know how I could overcome the problem?
Cheers, Memo.
p.d. thanks in advance ..
Glen Scales [MVP] wrote:
The code to delete entries is the same as to add or update a Distirubution
list your just adding or removing elements in the value array you do need to
write some code that will decode the property to identitfy the value you
want to delete i would suggest you use the oneoffmember property to do this
eg
DeleteDLEntry(esb,DL,"user@xxxxxxxxxx");
static void DeleteDLEntry(ExchangeServiceBinding esb,ItemType
dlDistibutionList, String cnContacttoDelete) {
NonEmptyArrayOfPropertyValuesType UpdatedMembersVal = new
NonEmptyArrayOfPropertyValuesType();
NonEmptyArrayOfPropertyValuesType CurrentMembersVal =
(NonEmptyArrayOfPropertyValuesType)dlDistibutionList.ExtendedProperty[0].Item;
NonEmptyArrayOfPropertyValuesType CurrentOneOffMembersVal =
(NonEmptyArrayOfPropertyValuesType)dlDistibutionList.ExtendedProperty[1].Item;
NonEmptyArrayOfPropertyValuesType UpdatedOneOffMembersVal = new
NonEmptyArrayOfPropertyValuesType();
List<DLEntry> DLEntries = new List<DLEntry>();
for (int vc = 0; vc < CurrentOneOffMembersVal.Items.Length; vc++)
{
DLEntry DlEntryVal = new DLEntry();
byte[] oneoffMemberEntrybinarry =
Convert.FromBase64String(CurrentOneOffMembersVal.Items[vc].ToString());
int emStart = 0;
String emEmailAddress = "";
for (int ssArraynum = (oneoffMemberEntrybinarry.Length - 4); ssArraynum !=
0; ssArraynum--)
{
if (oneoffMemberEntrybinarry[ssArraynum] == 0 &
oneoffMemberEntrybinarry[ssArraynum-1] == 0)
{
emStart = ssArraynum;
emEmailAddress =
System.Text.ASCIIEncoding.Unicode.GetString(oneoffMemberEntrybinarry,
emStart + 1, (oneoffMemberEntrybinarry.Length - (emStart + 3)));
ssArraynum = 1;
}
}
if (emEmailAddress.ToLower() != cnContacttoDelete.ToLower())
{
DlEntryVal.Member = CurrentMembersVal.Items[vc];
DlEntryVal.OneOffMember = CurrentOneOffMembersVal.Items[vc];
DLEntries.Add(DlEntryVal);
}
}
UpdatedMembersVal.Items = new String[DLEntries.Count];
UpdatedOneOffMembersVal.Items = new String[DLEntries.Count];
for (int lc=0;lc < DLEntries.Count;lc++){
UpdatedMembersVal.Items[lc] = DLEntries[lc].Member;
UpdatedOneOffMembersVal.Items[lc] = DLEntries[lc].OneOffMember;
}
UpdateDL(esb, dlDistibutionList.ItemId, UpdatedMembersVal,
UpdatedOneOffMembersVal);
}
static void UpdateDL(ExchangeServiceBinding esb, ItemIdType
dlDistributionList, NonEmptyArrayOfPropertyValuesType mnMembers,
NonEmptyArrayOfPropertyValuesType mnOneOffMembers) {
PathToExtendedFieldType DLMembers = new PathToExtendedFieldType();
DLMembers.PropertyId = 0x8055;
DLMembers.PropertyIdSpecified = true;
DLMembers.DistinguishedPropertySetId =
DistinguishedPropertySetType.Address;
DLMembers.DistinguishedPropertySetIdSpecified = true;
DLMembers.PropertyType = MapiPropertyTypeType.BinaryArray;
PathToExtendedFieldType DLOneoffMembers = new PathToExtendedFieldType();
DLOneoffMembers.PropertyId = 0x8054;
DLOneoffMembers.PropertyIdSpecified = true;
DLOneoffMembers.DistinguishedPropertySetId =
DistinguishedPropertySetType.Address;
DLOneoffMembers.DistinguishedPropertySetIdSpecified = true;
DLOneoffMembers.PropertyType = MapiPropertyTypeType.BinaryArray;
UpdateItemType updateItemType = new UpdateItemType();
updateItemType.ConflictResolution =
ConflictResolutionType.AlwaysOverwrite;
updateItemType.MessageDisposition = MessageDispositionType.SaveOnly;
updateItemType.MessageDispositionSpecified = true;
updateItemType.ItemChanges = new ItemChangeType[1];
ItemChangeType changeType = new ItemChangeType();
changeType.Item = dlDistributionList;
changeType.Updates = new ItemChangeDescriptionType[2];
SetItemFieldType setItemDLMembers = new SetItemFieldType();
SetItemFieldType setItemDLOnOffMembers = new SetItemFieldType();
ExtendedPropertyType DLoneoffExProp = new ExtendedPropertyType();
DLoneoffExProp.ExtendedFieldURI = DLOneoffMembers;
DLoneoffExProp.Item = mnOneOffMembers;
ExtendedPropertyType DLMembersExProp = new ExtendedPropertyType();
DLMembersExProp.ExtendedFieldURI = DLMembers;
DLMembersExProp.Item = mnMembers;
ItemType DLOneoffMembersItem = new ItemType();
DLOneoffMembersItem.ExtendedProperty = new ExtendedPropertyType[1];
DLOneoffMembersItem.ExtendedProperty[0] = DLoneoffExProp;
ItemType DLMembersItem = new ItemType();
DLMembersItem.ExtendedProperty = new ExtendedPropertyType[1];
DLMembersItem.ExtendedProperty[0] = DLMembersExProp;
setItemDLMembers.Item = DLMembers;
setItemDLOnOffMembers.Item = DLOneoffMembers;
setItemDLMembers.Item1 = DLMembersItem;
setItemDLOnOffMembers.Item1 = DLOneoffMembersItem;
changeType.Updates[0] = setItemDLMembers;
changeType.Updates[1] = setItemDLOnOffMembers;
updateItemType.ItemChanges[0] = changeType;
// Send the update item request and receive the response
UpdateItemResponseType updateItemResponse =
esb.UpdateItem(updateItemType);
if (updateItemResponse.ResponseMessages.Items[0].ResponseClass ==
ResponseClassType.Success)
{
Console.WriteLine("Update Successful");
}
else
{
--
Message posted via WinServerKB.com
http://www.winserverkb.com/Uwe/Forums.aspx/ms-exchange-development/200810/1
.
- Follow-Ups:
- Re: żIs it possible to create a contact in Exchange 2007 with webdav operations?
- From: Glen Scales [MVP]
- Re: żIs it possible to create a contact in Exchange 2007 with webdav operations?
- References:
- Re: ¿Is it possible to create a contact in Exchange 2007 with webdav operations?
- From: shades_80 via WinServerKB.com
- Re: żIs it possible to create a contact in Exchange 2007 with webdav operations?
- From: Glen Scales [MVP]
- Re: ¿Is it possible to create a contact in Exchange 2007 with webdav operations?
- From: shades_80 via WinServerKB.com
- Re: żIs it possible to create a contact in Exchange 2007 with webdav operations?
- From: Glen Scales [MVP]
- Re: ¿Is it possible to create a contact in Exchange 2007 with webdav operations?
- From: shades_80 via WinServerKB.com
- Re: żIs it possible to create a contact in Exchange 2007 with webdav operations?
- From: Glen Scales [MVP]
- Re: ¿Is it possible to create a contact in Exchange 2007 with webdav operations?
- From: shades_80 via WinServerKB.com
- Re: żIs it possible to create a contact in Exchange 2007 with webdav operations?
- From: Glen Scales [MVP]
- Re: ¿Is it possible to create a contact in Exchange 2007 with webdav operations?
- From: shades_80 via WinServerKB.com
- Re: żIs it possible to create a contact in Exchange 2007 with webdav operations?
- From: Glen Scales [MVP]
- Re: ¿Is it possible to create a contact in Exchange 2007 with webdav operations?
- Prev by Date: Re: żIs it possible to create a contact in Exchange 2007 with webdav operations?
- Next by Date: Re: żIs it possible to create a contact in Exchange 2007 with webdav operations?
- Previous by thread: Re: żIs it possible to create a contact in Exchange 2007 with webdav operations?
- Next by thread: Re: żIs it possible to create a contact in Exchange 2007 with webdav operations?
- Index(es):
Relevant Pages
|