Exchaneg Web Services

Newman 1 Reputation point

Hi All
A newbie to this site, so apologies if I don't do it right the first time

I need help with Exchange Web Services. I have managed to connect and send an email. Simple

But my goal is to create an apsx page that will have information input and then have it sent into exchange contacts so they can be sync to my phone. Currently having to enter contact details into a number of different systems . Hence my goal to try to enter the information once.

My code is below and my problem is the line

Contact contact = new Contact(service);

I get an error as follows

Error CS1729 'Contact' does not contain a constructor that takes 1 arguments

I am using the following name space

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Net;
using System.Security;
using Microsoft.Exchange.WebServices.Data;
using System.Web.Services;

with the code below

// Connect to Exchange Web Services as user1 at contoso.com.
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1, TimeZoneInfo.Utc);
service.Credentials = new WebCredentials("user@keyman .com", "password");
service.AutodiscoverUrl("user@keyman .com", RedirectionCallback);

        System.Diagnostics.Debug.WriteLine("EWS Endpoint: {0}", service.Url);  

        Contact contact = new Contact(service);  

I know it is probably a simple thing but, I just cannot find anything anywhere to help me sort this out. if I cannot clear this error none of the fields are recognised in the rest of the code to create the contact

SO, I hope someone can help

Thanks in advance

Exchange Server Development
Exchange Server Development
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Development: The process of researching, productizing, and refining new or existing technologies.
340 questions
{count} votes

4 answers

Sort by: Most helpful
  1. Glen Scales 3,971 Reputation points MVP

    That should work there is nothing wrong with your syntax, is this in a separate method or class ? is it possibly resolving to a different Contact class the name is generic so you could try fully qualifying it to see if that makes a difference eg (you shouldn't have to do this but its worth trying)

    Microsoft.Exchange.WebServices.Data.Contact contact = new Microsoft.Exchange.WebServices.Data.Contact(service);

  2. Newman 1 Reputation point

    Yes, I figured it out. It was confusing itself with another bit of code. Once I isolated it. It worked like a dream


  3. natan jikwa 1 Reputation point
  4. natan jikwa 1 Reputation point