Re: ¿Is it possible to create a contact in Exchange 2007 with webdav operations?
- From: "shades_80 via WinServerKB.com" <u46887@uwe>
- Date: Tue, 21 Oct 2008 22:43:49 GMT
By 70,502 time thank to you a goal was gotten, now the new C# application is
able to create a distribution list in a public folder in Exchange 2007.
Unfortunately, I haven´t still been able to create another contact over the
same distribution list. ¿Do you know how to do add more contacts to the same
distribution list?
Thanks in advance.
Memo.
Glen Scales [MVP] wrote:
My code to create DL's and add recepient one off recipients that i know
works is as follows ( i haven't really cleaned it up)
CreateItemType ciCreateItem = new CreateItemType();
ciCreateItem.MessageDisposition = MessageDispositionType.SaveOnly;
ciCreateItem.MessageDispositionSpecified = true;
DistinguishedFolderIdType ditype = new DistinguishedFolderIdType();
ditype.Id = DistinguishedFolderIdNameType.contacts;
BaseFolderIdType[] biarray = new BaseFolderIdType[1]{ditype};
ItemType dlDL = new ItemType();
dlDL.ItemClass = "IPM.DistList";
ExtendedPropertyType exProp1 = new ExtendedPropertyType();
ExtendedPropertyType exProp2 = new ExtendedPropertyType();
ExtendedPropertyType exProp3 = new ExtendedPropertyType();
ExtendedPropertyType exProp4 = new ExtendedPropertyType();
ExtendedPropertyType exProp5 = new ExtendedPropertyType();
ExtendedPropertyType exProp6 = new ExtendedPropertyType();
PathToExtendedFieldType DLNameprop1 = new PathToExtendedFieldType();
DLNameprop1.PropertyId = 0x8053;
DLNameprop1.PropertyIdSpecified = true;
DLNameprop1.DistinguishedPropertySetId =
DistinguishedPropertySetType.Address;
DLNameprop1.DistinguishedPropertySetIdSpecified = true;
DLNameprop1.PropertyType = MapiPropertyTypeType.String;
PathToExtendedFieldType DLFileAs = new PathToExtendedFieldType();
DLFileAs.PropertyId = 0x8005;
DLFileAs.PropertyIdSpecified = true;
DLFileAs.DistinguishedPropertySetId = DistinguishedPropertySetType.Address;
DLFileAs.DistinguishedPropertySetIdSpecified = true;
DLFileAs.PropertyType = MapiPropertyTypeType.String;
PathToExtendedFieldType DLDisplayNameprop = new PathToExtendedFieldType();
DLDisplayNameprop.PropertyTag = "0x3001";
DLDisplayNameprop.PropertyType = MapiPropertyTypeType.String;
String DlName = "test1234";
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;
String oneoffprefix = "00000000812B1FA4BEA310199D6E00DD010F540200000190";
String oneoffpadd = "0000";
String oneoffhex = oneoffprefix + ConvertToHex("Freds Mail") + oneoffpadd +
ConvertToHex("SMTP") + oneoffpadd + ConvertToHex("fred@xxxxxxxx") +
oneoffpadd;
Byte[] oneOffarray = HexStringToByteArray(oneoffhex);
String WrappedEntryIDPrefix = "00000000C091ADD3519DCF11A4A900AA0047FAA4C3";
String ContactEntryID = "00000000...etc";
Byte[] Membersarray = HexStringToByteArray((WrappedEntryIDPrefix +
ContactEntryID));
NonEmptyArrayOfPropertyValuesType MembersVal = new
NonEmptyArrayOfPropertyValuesType();
MembersVal.Items = new String[1];
MembersVal.Items[0] = Convert.ToBase64String(Membersarray);
NonEmptyArrayOfPropertyValuesType OneOffMembersVal = new
NonEmptyArrayOfPropertyValuesType();
OneOffMembersVal.Items = new String[1];
OneOffMembersVal.Items[0] = Convert.ToBase64String(oneOffarray);
exProp1.ExtendedFieldURI = DLNameprop1;
exProp1.Item = DlName;
exProp2.ExtendedFieldURI = DLDisplayNameprop;
exProp2.Item = DlName;
exProp3.ExtendedFieldURI = DLFileAs;
exProp3.Item = DlName;
exProp4.ExtendedFieldURI = DLMembers;
exProp4.Item = MembersVal;
exProp5.ExtendedFieldURI = DLOneoffMembers;
exProp5.Item = OneOffMembersVal;
dlDL.Subject = DlName;
dlDL.ExtendedProperty = new ExtendedPropertyType[5];
dlDL.ExtendedProperty[0] = exProp1;
dlDL.ExtendedProperty[1] = exProp2;
dlDL.ExtendedProperty[2] = exProp3;
dlDL.ExtendedProperty[3] = exProp4;
dlDL.ExtendedProperty[4] = exProp5;
TargetFolderIdType tfTarget = new TargetFolderIdType();
tfTarget.Item = ditype;
ciCreateItem.SavedItemFolderId = tfTarget;
ciCreateItem.Items = new NonEmptyArrayOfAllItemsType();
ciCreateItem.Items.Items = new ItemType[1];
ciCreateItem.Items.Items[0] = dlDL;
CreateItemResponseType cirespn = esb.CreateItem(ciCreateItem);
public static byte[] HexStringToByteArray(string Hex)
{
byte[] Bytes;
int ByteLength;
string HexValue =
"\x0\x1\x2\x3\x4\x5\x6\x7\x8\x9|||||||\xA\xB\xC\xD\xE\xF";
ByteLength = Hex.Length / 2;
Bytes = new byte[ByteLength];
for (int x = 0, i = 0; i < Hex.Length; i += 2, x += 1)
{
Bytes[x] = (byte)(HexValue[Char.ToUpper(Hex[i + 0]) - '0'] << 4);
Bytes[x] |= (byte)(HexValue[Char.ToUpper(Hex[i + 1]) - '0']);
}
return Bytes;
}
static string ConvertToHex(string asciiString)
{
string hex = "";
foreach (char c in asciiString)
{
int tmp = c;
hex += String.Format("{0:x2}",
(uint)System.Convert.ToUInt32(tmp.ToString())) + "00";
}
return hex;
}
Cheers
Glen
With your tips I could give a big step, now the new C# application is able[quoted text clipped - 124 lines]
to
Memo.
--
Message posted via http://www.winserverkb.com
.
- 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?
- Prev by Date: Could not load file or assembly 'Microsoft.Rtc.Collaboration'
- 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):