Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problems creating real contacts with WebDAV

10 views
Skip to first unread message

dawie

unread,
Jul 6, 2009, 10:18:42 AM7/6/09
to
I'm using WebDav to create new contacts on an exchange server in a
personal contact folder.
When I write an email to one of that created contact (by i.g.writing
the last name of that contact) outlook does'nt offer me completition
of that name - neither knows that contact. when i manually create a
new contact in the same folder, everything work's as expected.
is there a special contact property to activate that completition
feature or are the some special settings in outlook needed?

Thanks,
David

a@tleederbyshired.0.tc.0.m Lee Derbyshire [MVP]

unread,
Jul 6, 2009, 11:40:37 AM7/6/09
to
"dawie" <pop...@gmail.com> wrote in message
news:105d851a-bcb6-433b...@a36g2000yqc.googlegroups.com...

It would help to see the code you are using. Contacts have a /lot/ of
addressing properties, one of which you could easily have overlooked.

Lee.

--
______________________________________

Outlook Web Access For PDA , OWA For WAP
www.leederbyshire.com
lee a.t leederbyshire d.o.t c.o.m
______________________________________


dawie

unread,
Jul 7, 2009, 5:18:06 AM7/7/09
to
On Jul 6, 5:40 pm, "Lee Derbyshire [MVP]" <email a@t leederbyshire d.

This is my method for inserting new contacts:

public void insertContact(iadrblue_SoapInterfaceOutlookKontaktStruct
contact) {
try {
string sUri = exchangeServer + "/" + exchangePath + "/" +
contact.FirstName + "%20" + contact.LastName + "-" + contact.Id +
".eml";
logger.Debug(" * " + "Creating new contact: " + sUri);

System.Uri myUri = new System.Uri(sUri);
HttpWebRequest HttpWRequest = (HttpWebRequest)WebRequest.Create
(myUri);

// Der komplette Name, kommasepariert
string completeName = "";
if (contact.LastName != "") {
completeName += contact.LastName;
}
if (contact.FirstName != "") {
if (contact.LastName != "") {
completeName += ", ";
}
completeName += contact.FirstName;
}

// Querystring mit allen Infos zusammenbauen
string sQuery = "<?xml version='1.0' encoding='UTF-8' ?>" +

"<g:propertyupdate xmlns:g='DAV:' xmlns:c='urn:schemas:contacts:'
xmlns:e='http://schemas.microsoft.com/exchange/' xmlns:mapi='http://
schemas.microsoft.com/mapi/' xmlns:x='xml:'
xmlns:cal='urn:schemas:calendar:' xmlns:mail='urn:schemas:httpmail:'>"
+
"<g:set><g:prop>" +
"<g:contentclass>urn:content-classes:person</g:contentclass>" +

"<e:outlookmessageclass>IPM.Contact</e:outlookmessageclass>" +

"<c:fileas>" + completeName + "</c:fileas>"
+
"<c:givenName>" + contact.FirstName + "</
c:givenName>" +
"<c:sn>" + contact.LastName + "</c:sn>" +
"<c:cn>" + contact.FirstName + " " +
contact.LastName + "</c:cn>" +
"<c:personaltitle>" + contact.Title + "</
c:personaltitle>" +

"<c:street>" + contact.BusinessStreet + "</c:street>"
+
"<c:l>" + contact.BusinessCity + "</c:l>" +
"<c:postalcode>" + contact.BusinessPostalCode + "</
c:postalcode>" +
"<c:co>" + contact.BusinessCountry + "</c:co>" +

"<c:department>" + contact.Department + "</
c:department>" +
"<c:title>" + contact.JobTitle + "</c:title>" +
"<c:profession>" + contact.Position + "</
c:profession>" +
"<c:secretarycn>" + contact.AssistantsName + "</
c:secretarycn>" +
"<c:secretaryphone>" + contact.AssistantsPhone + "</
c:secretaryphone>" +

"<c:otherstreet>" + contact.OtherStreet + "</
c:otherstreet>" +
"<c:othercity>" + contact.OtherCity + "</
c:othercity>" +
"<c:otherpostalcode>" + contact.OtherPostalCode + "</
c:otherpostalcode>" +
"<c:othercountry>" + contact.OtherCountry + "</
c:othercountry>" +
"<c:otherfax>" + contact.OtherFaxNumber + "</
c:otherfax>" +


"<c:telephoneNumber>" + contact.BusinessPhone + "</
c:telephoneNumber>" +
"<c:telephonenumber2>" + contact.Business2TelephoneNumber + "</
c:telephonenumber2>" +
"<c:facsimiletelephonenumber>" + contact.BusinessFax + "</
c:facsimiletelephonenumber>" +

"<c:homePhone>" + contact.HomePhone + "</c:homePhone>" +
"<c:homephone2>" + contact.HomePhone2 + "</c:homephone2>" +
"<c:homefax>" + contact.HomeFaxNumber + "</c:homefax>" +
"<c:mobile>" + contact.MobilePhone + "</c:mobile>" +

"<c:businesshomepage>" + contact.WebPage + "</c:businesshomepage>"
+
"<c:birthday>" + contact.Birthday + "</c:birthday>" +

"<c:mailingaddressid>2</c:mailingaddressid>" +
"<c:o>" + contact.Company + "</c:o>" +

"<mail:subject>" + contact.FirstName + " " + contact.LastName + "</
mail:subject>" +

"<mapi:email1addrtype>SMTP</mapi:email1addrtype>" +
"<mapi:email1emailaddress>" + contact.EmailAddress + "</
mapi:email1emailaddress>" +
"<mapi:email1originaldisplayname>" + contact.EmailAddress + "</
mapi:email1originaldisplayname>" +

"<mapi:email2addrtype>SMTP</mapi:email2addrtype>" +
"<mapi:email2emailaddress>" + contact.Email2Address + "</
mapi:email2emailaddress>" +
"<mapi:email2originaldisplayname>" + contact.Email2Address + "</
mapi:email2originaldisplayname>" +

"<mapi:email3addrtype>SMTP</mapi:email3addrtype>" +
"<mapi:email3emailaddress>" + contact.Email3Address + "</
mapi:email3emailaddress>" +
"<mapi:email3originaldisplayname>" + contact.Email3Address + "</
mapi:email3originaldisplayname>" +

"</g:prop></g:set>" +
"</g:propertyupdate>";


// Set the credentials.
NetworkCredential myCred = new NetworkCredential(userName,
userPasswd);
CredentialCache myCredentialCache = new CredentialCache();
myCredentialCache.Add(myUri, "Basic", myCred);
HttpWRequest.Credentials = myCredentialCache;

// Set the headers.
HttpWRequest.KeepAlive = false;
HttpWRequest.Headers.Set("Pragma", "no-cache");
HttpWRequest.ContentType = "text/xml";
HttpWRequest.ContentLength = sQuery.Length;

//Set the request timeout to 5 minutes.
HttpWRequest.Timeout = 300000;

// set the request method
HttpWRequest.Method = "PROPPATCH";

// Store the data in a byte array.
byte[] ByteQuery = System.Text.Encoding.UTF8.GetBytes
(sQuery);
HttpWRequest.ContentLength = ByteQuery.Length;
Stream QueryStream = HttpWRequest.GetRequestStream();

// write the data to be posted to the Request Stream
QueryStream.Write(ByteQuery, 0, ByteQuery.Length);
QueryStream.Close();

// Send the request and get the response,
HttpWebResponse HttpWResponse = (HttpWebResponse)
HttpWRequest.GetResponse();

// Get the Status code
int iStatCode = (int)HttpWResponse.StatusCode;
string sStatus = iStatCode.ToString();
logger.Debug(" * " + "Status Code: " + sStatus);

// Get the request headers
string sReqHeaders = HttpWRequest.Headers.ToString();

// Read the Response Steam
Stream strm = HttpWResponse.GetResponseStream();
StreamReader sr = new StreamReader(strm);
string sText = sr.ReadToEnd();

// Close the stream.
strm.Close();

// Clean up
myCred = null;
myCredentialCache = null;
HttpWRequest = null;
HttpWResponse = null;
QueryStream = null;
strm = null;
sr = null;

} catch (Exception e) {
logger.Error("Fehler beim Anlegen eines Kontaktes: " +
e.Message + ", " + e.StackTrace);
}
}

David

a@tleederbyshired.0.tc.0.m Lee Derbyshire [MVP]

unread,
Jul 7, 2009, 8:50:42 AM7/7/09
to

The only property I can see that is missing (compared to what I usually do)
is:

http://schemas.microsoft.com/mapi/emaillisttype

which I usually set to 1. I would suggest adding this line, just before you
set the three email addresses:

<mapi:emaillisttype>1</mapi:emaillisttype>" +

Lee.

--
______________________________________

Outlook Web Access For PDA , OWA For WAP
www.leederbyshire.com
lee a.t leederbyshire d.o.t c.o.m
______________________________________

"dawie" <pop...@gmail.com> wrote in message
news:d061a572-ac1e-4184...@32g2000yqj.googlegroups.com...

dawie

unread,
Jul 8, 2009, 12:24:39 PM7/8/09
to
...and that was the missing property - thank you so much!!

It's so interesting that MS does'nt make mention of that property in
their article "How to create Contact items in Visual C# on a computer
that is running Exchange 2000 Server" (http://support.microsoft.com/kb/
313119).

David

On Jul 7, 2:50 pm, "Lee Derbyshire [MVP]" <email a@t leederbyshire d.


0.t c.0.m> wrote:
> The only property I can see that is missing (compared to what I usually do)
> is:
>
> http://schemas.microsoft.com/mapi/emaillisttype
>
> which I usually set to 1.  I would suggest adding this line, just before you
> set the three email addresses:
>
> <mapi:emaillisttype>1</mapi:emaillisttype>" +
>
> Lee.
>
> --
> ______________________________________
>

a@tleederbyshired.0.tc.0.m Lee Derbyshire [MVP]

unread,
Jul 8, 2009, 1:07:49 PM7/8/09
to

It's kind of a tradition that Exchange API documentation has at least /some/
of the important information missing. :-) When people get too good at it,
they'll scrap it and replace it with another one.

Lee.

--
_______________________________________

Outlook Web Access for PDA, OWA For WAP:
www.leederbyshire.com
________________________________________

"dawie" <pop...@gmail.com> wrote in message

news:9a23c54c-0dfb-42d6...@h18g2000yqj.googlegroups.com...

0 new messages