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 00:16:39 GMT
With your tips I could give a big step, now the new C# application is able to
create a contact in a public folder in Exchange 2007 SP1.
The actual problem is with the code to create the distribution list that I
found in the page you suggested me. I don't know but maybe a library
declaration is missing because there were 50 the errors that appeared after I
added that code. Below I write some of them:
1 The name 'BodyType1' does not exist in the current contextError
2 The name 'Value' does not exist in the current context
3 The name 'ExtendedFieldURI' does not exist in the current context
4 The name 'Item' does not exist in the current context
16 The name 'Format' does not exist in the current context
17 The name 'Id' does not exist in the current context
18 The name 'esb' does not exist in the current context
19 'string' does not contain a definition for 'ToByteArray'
20 The type or namespace name 'var' could not be found (are you missing a
using directive or an assembly reference?
Have you tried to create a distribution list using the code that you
suggested me?
Any extra help would be very appreciated!
Cheers, Memo.
Glen Scales [MVP] wrote:
To create anything in a public folder you need to first know the EWS
folderID of the Public folder you want to create the item in. Generally the
easist way to do this is just include a FindFolder operation in your code
first to find the folderID. Eg if you wanted to find a folder called "Public
Contacts Folder" that is a root folder in the public folder tree something
like this would work
String fnFolderName = "Public Contacts Folder";
FolderIdType pfPublicFolderID = null;
DistinguishedFolderIdType diFolder = new
DistinguishedFolderIdType();
diFolder.Id = DistinguishedFolderIdNameType.publicfoldersroot;
BaseFolderIdType[] biArray = new BaseFolderIdType[1] {
diFolder };
FindFolderType fiFindFolder = new FindFolderType();
fiFindFolder.Traversal = FolderQueryTraversalType.Shallow;
FolderResponseShapeType rsResponseShape = new
FolderResponseShapeType();
rsResponseShape.BaseShape = DefaultShapeNamesType.AllProperties;
fiFindFolder.FolderShape = rsResponseShape;
fiFindFolder.ParentFolderIds = biArray;
//Add Restriction for DisplayName
RestrictionType ffRestriction = new RestrictionType();
IsEqualToType ieToType = new IsEqualToType();
PathToUnindexedFieldType fnFolderNameField = new
PathToUnindexedFieldType();
fnFolderNameField.FieldURI =
UnindexedFieldURIType.folderDisplayName;
FieldURIOrConstantType ciConstantType = new
FieldURIOrConstantType();
ConstantValueType cvConstantValueType = new ConstantValueType();
cvConstantValueType.Value = fnFolderName;
ciConstantType.Item = cvConstantValueType;
ieToType.Item = fnFolderNameField;
ieToType.FieldURIOrConstant = ciConstantType;
ffRestriction.Item = ieToType;
fiFindFolder.Restriction = ffRestriction;
FindFolderResponseType findFolderResponse =
esb.FindFolder(fiFindFolder);
ResponseMessageType[] rmta =
findFolderResponse.ResponseMessages.Items;
foreach (ResponseMessageType rmt in rmta)
{
if (((FindFolderResponseMessageType)rmt).ResponseClass ==
ResponseClassType.Success)
{
FindFolderResponseMessageType ffResponse =
(FindFolderResponseMessageType)rmt;
if (ffResponse.RootFolder.TotalItemsInView > 0)
{
pfPublicFolderID =
ffResponse.RootFolder.Folders[0].FolderId;
}
}
}
The you can just use code such as
http://msdn.microsoft.com/en-us/library/aa563318(EXCHG.80).aspx all you need
to change is the source folder eg change
// Because you are creating a contact, save the item in the Contacts
folder.
createItemType.SavedItemFolderId = new TargetFolderIdType();
DistinguishedFolderIdType contactsFolder = new
DistinguishedFolderIdType();
contactsFolder.Id = DistinguishedFolderIdNameType.contacts;
createItemType.SavedItemFolderId.Item = contactsFolder;
With the result of the findFolder operation eg
// Because you are creating a contact, save the item in the Public
Contacts folder.
createItemType.SavedItemFolderId = new TargetFolderIdType();
createItemType.SavedItemFolderId.Item = pfPublicFolderID;
There is no direct support for creating Distribution lists in EWS or WebDAV
you can do this however by manipulating the Mapi properties assoicated with
the object have a look at the sample on
http://wdeconinck.wordpress.com/2008/10/06/exchange-webservice-creating-a-distribution-list/
Cheers
Glen
To be honest, I will need to ask to the person who installed Exchange[quoted text clipped - 63 lines]
Server
Memo.
--
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?
- Prev by Date: Re: FindItem without knowing the password?
- Next by Date: Re: żIs it possible to create a contact in Exchange 2007 with webdav operations?
- Previous by thread: Re: Subscribing to Exchange Server
- Next by thread: Re: żIs it possible to create a contact in Exchange 2007 with webdav operations?
- Index(es):
Relevant Pages
|