Re: ¿Is it possible to create a contact in Exchange 2007 with webdav operations?

Tech-Archive recommends: Fix windows errors by optimizing your registry



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
Server
[quoted text clipped - 63 lines]

Memo.

--
Message posted via WinServerKB.com
http://www.winserverkb.com/Uwe/Forums.aspx/ms-exchange-development/200810/1

.



Relevant Pages

  • Re: Email enable doc lib
    ... navigate to the public folder and send some posts with attachments to the ... Microsoft CSS Online Newsgroup Support ... I have disabled forms base Athentication from the default V.Smtp server ...
    (microsoft.public.windows.server.sbs)
  • Re: Public Folder Limits FAQ?
    ... mailbox and public. ... public folders - by default those appearing in the Public Folder Favorites ... any limitations you will experience by going to Exchange. ...
    (microsoft.public.windows.server.sbs)
  • Re: NTBackup and Exchange
    ... public folder store because it contains folder replicas. ... and Pub IS for Exchange. ...
    (microsoft.public.exchange.admin)
  • RE: Mailbox v Public Folder
    ... Right click the folder and click Properties. ... Check Outlook Permission settings: ... which needs to configure this public folder. ... Microsoft CSS Online Newsgroup Support ...
    (microsoft.public.windows.server.sbs)
  • Re: Removing Empty, but Replicated Public Folders
    ... You do have Exchange 2003 folders, ... When I go to the E2K7 Server's Public Folder Database, ... it will not let me remove the replicas - ...
    (microsoft.public.exchange.admin)