Announcement

Collapse
No announcement yet.

Kontakte im Exchange Server 2007 autom. anlegeb

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Kontakte im Exchange Server 2007 autom. anlegeb

    Hallo!

    Ich möchte gerne automatisiert (VB.NET) Kontakte im Öffentlichen Ordner Exchange Server 2007) anlegen.

    Welche Vorgangsweise gibt es dazu?

    Besten Dank
    Chris

  • #2
    hier ist ein Beispiel auf C#, das du (hoffe ich ) auf VB überlegen kannst.
    [highlight=c#]

    Import Microsoft.ServiceModel.Channels.Mail.ExchangeWebSe rvice.Exchange2007

    // Create the bindings and set the credentials.
    ExchangeServiceBinding esb = new ExchangeServiceBinding();
    esb.Url = "http://blablabla/exchange.asmx";

    esb.Credentials = new NetworkCredential("UserName", "Password", "Domain");

    // Create an object of create item type.
    CreateItemType createItemType = new CreateItemType();

    // 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;

    createItemType.Items = new NonEmptyArrayOfAllItemsType();
    createItemType.Items.Items = new ItemType[1];

    // Create a contact item type.
    ContactItemType contactItem = new ContactItemType();

    // Set the relevant properties on the contact.
    contactItem.FileAs = "Person 1";

    // Set the contact name and job information.
    contactItem.GivenName = "Gates";
    contactItem.Surname = "William Henry III";
    contactItem.CompanyName = "MS";
    contactItem.JobTitle = "Vorsitzender";

    // Set a single e-mail address for the contact.
    contactItem.EmailAddresses = new EmailAddressDictionaryEntryType[1];
    EmailAddressDictionaryEntryType address = new EmailAddressDictionaryEntryType();
    address.Key = EmailAddressKeyType.EmailAddress1;
    address.Value = "[email protected]";
    contactItem.EmailAddresses[0] = address;

    // Set a single contact physical address.
    contactItem.PhysicalAddresses = new PhysicalAddressDictionaryEntryType[1];
    PhysicalAddressDictionaryEntryType physicalAddress = new PhysicalAddressDictionaryEntryType();
    physicalAddress.Key = PhysicalAddressKeyType.Home;
    physicalAddress.Street = "Blablabla";
    physicalAddress.City = "Redmond";
    physicalAddress.Country = "United States";
    physicalAddress.PostalCode = "11111";

    contactItem.PhysicalAddresses[0] = physicalAddress;

    // Set the contact telephone number.
    contactItem.PhoneNumbers = new PhoneNumberDictionaryEntryType[1];
    PhoneNumberDictionaryEntryType phoneEntry = new PhoneNumberDictionaryEntryType();
    phoneEntry.Key = PhoneNumberKeyType.BusinessPhone;
    phoneEntry.Value = "5625550100";

    contactItem.PhoneNumbers[0] = phoneEntry;

    createItemType.Items.Items[0] = contactItem;

    // Send the request to create the contact item; receive the response.
    CreateItemResponseType createItemResponse = esb.CreateItem(createItemType);

    // Check the results of the request.
    if (createItemResponse.ResponseMessages.Items.Length > 0 &&
    createItemResponse.ResponseMessages.Items[0].ResponseClass == ResponseClassType.Success)
    {
    ItemInfoResponseMessageType responseMessage = createItemResponse.ResponseMessages.Items[0] as ItemInfoResponseMessageType;
    ContactItemType contactResponse = responseMessage.Items.Items[0] as ContactItemType;
    Console.WriteLine("Created Contact Item with Id {0} and ChangeKey {1}", contactResponse.ItemId.Id, contactResponse.ItemId.ChangeKey);
    }

    [/highlight]
    Zuletzt editiert von vadym voytas; 06.10.2009, 22:08.
    Bitte vergessen Sie nicht die Antwort zu bewerten. Danke.:-)

    Comment


    • #3
      Danke!

      Werde den Code übersetzen und ausprobieren.

      Beste Grüße
      Chris

      Comment

      Working...
      X