WebDav - Outlook Contact Notes Field

  • Thread starter Sumanth Peddi via OfficeKB.com
  • Start date
S

Sumanth Peddi via OfficeKB.com

am trying to insert a contact into outlook contact folder of a user using
WebDav API and VB.NET. I am following the sample code listed below. The
problem that I am facing is updating notes pertaining to a contact. I have
been trying <c:notes>Test Notes</c:notes> and <c:comments>Test
Notes<c:comments>, but none of these seem to work. Do you happen to know the

exact tag name that maps to notes filed of a contact in outlook.

Dim strEmailInfo As String
Dim strOrganizationalInfo As String
Dim strPersonalInfo As String
Dim strCustomerInfo As String
Dim strFollowUpInfo As String
Dim strMiscInfo As String
Dim strUserFieldsInfo As String

Dim objRequest As MSXML2.XMLHTTP
Dim contactname As String = "Doe, John"
Dim strnameinfo As String
Dim strbusinessaddrinfo As String
Dim strHomeAddrInfo As String
Dim strOtherAddrInfo As String
Dim strMailAddrInfo As String
Dim strPhoneInfo As String

Dim strBody As String
Dim strXMLNSInfo As String
Dim strURL As String
Dim strResult As String = "Success"
' Dim myConnection As New
SqlConnection("Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security
Info=False;Initial Catalog=FlexPoint_contacts;Data Source=exch01\bkupexec")
'Dim szSQL As String = " Select * From Flex_UsersContactList where
ContactID=" & CInt(ContactID)
'Dim myDataAdapter As New SqlDataAdapter(szSQL, myConnection)
'Dim ds As New DataSet
'Dim myUserName As String
'myDataAdapter.Fill(ds)
Dim myString As String =
System.Configuration.ConfigurationSettings.AppSettings("MailServer").ToString
' Specify the URL of the new object to be created.
'strURL = "http://ServerName/Exchange/UserName/Contacts/John Doe.eml"
'strURL = myString & "/speddi/Contacts/John Doe.eml"
strURL = myString & "/pla/Contacts/John Doe.eml"
' Create an HTTP request object.
'objRequest = CreateObject("Microsoft.xmlhttp")
objRequest = New MSXML2.XMLHTTP

' Specify the Namespaces to be used.

strXMLNSInfo = "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:"">"
' Specify the contact's name information.
' (First Name, Middle Name, Last Name, Full Name,
' Subject of the contact--used by Outlook Address Book,
' File As, Initials, Nickname, Title, and Suffix)
strnameinfo = "<c:givenName>John1234143</c:givenName>" & _
"<c:middlename>Jacob</c:middlename>" & _
"<c:sn>Doe</c:sn>" & _
"<c:cn>John J. Doe</c:cn>" & _
"<mail:subject>John Doe</mail:subject>" & _
"<c:fileas>Doe, John</c:fileas>" & _
"<c:initials>JJD</c:initials>" & _
"<c:nickname>Johnnie</c:nickname>" & _
"<c:personaltitle>Mr.</c:personaltitle>" & _
"<c:namesuffix>MCSD</c:namesuffix>" & _
"<c:contactnote>Test</c:contactnote>" & _
"<e:contactnote>Test</e:contactnote>" & _
"<c:prncontactnote>Test</c:prncontactnote>"
' Specify the Business Address Information.
' (Street, PO Box, City, State, Postal Code, and Country)
strbusinessaddrinfo = "<c:street>One Microsoft Way</c:street>" & _
"<c:postofficebox>PO Box 12345</c:postofficebox>" & _
"<c:l>Redmond</c:l>" & _
"<c:st>WA</c:st>" & _
"<c:postalcode>98052-6399</c:postalcode>" & _
"<c:co>USA</c:co>"
' Specify the Home Address Information.
' (Street, PO Box, City, State, Postal Code, and Country)
strHomeAddrInfo = "<c:homeStreet>500 Main Street</c:homeStreet>" & _
"<c:homepostofficebox>PO Box 54321</c:homepostofficebox>" & _
"<c:homeCity>Bellevue</c:homeCity>" & _
"<c:homeState>WA</c:homeState>" & _
"<c:homePostalCode>98004</c:homePostalCode>" & _
"<c:homeCountry>USA</c:homeCountry>"
' Specify the Other Address Information.
' (Street, PO Box, City, State, Postal Code, and Country)
strOtherAddrInfo = "<c:eek:therstreet>99 Myrtle Ave</c:eek:therstreet>" & _
"<c:eek:therpostofficebox>PO Box 98765</c:eek:therpostofficebox>" & _
"<c:eek:thercity>Green Cove Springs</c:eek:thercity>" & _
"<c:eek:therstate>FL</c:eek:therstate>" & _
"<c:eek:therpostalcode>32043</c:eek:therpostalcode>" & _
"<c:eek:thercountry>USA</c:eek:thercountry>"
' Specify which address is the mailing address.
' 0 = None, 1 = Home, 2 = Business, 3 = Other
strMailAddrInfo = "<c:mailingaddressid>2</c:mailingaddressid>"
' Specify phone number information.
' (Business Phone, Business Phone 2, Business Fax,
' Home Phone, Home Phone 2, Home Fax,
' Other Phone, Other Fax, Pager, Mobile Phone,
' Car Phone, ISDN, Telex, TTY/TDD, Callback)
strPhoneInfo = "<c:telephoneNumber>425-555-1110</c:telephoneNumber>"
& _
"<c:telephonenumber2>425-555-1111</c:telephonenumber2>" & _

"<c:facsimiletelephonenumber>425-555-1112</c:facsimiletelephonenumber>" & _
"<c:homePhone>425-555-1113</c:homePhone>" & _
"<c:homephone2>425-555-1114</c:homephone2>" & _
"<c:homefax>425-555-1115</c:homefax>" & _
"<c:eek:therTelephone>904-555-1111</c:eek:therTelephone>" & _
"<c:eek:therfax>904-555-1112</c:eek:therfax>" & _
"<c:pager>425-555-1116</c:pager>" & _
"<c:mobile>425-555-1117</c:mobile>" & _
"<c:eek:thermobile>904-555-1113</c:eek:thermobile>" & _

"<c:internationalisdnnumber>425-555-1118</c:internationalisdnnumber>" & _
"<c:telexnumber>425-555-1119</c:telexnumber>" & _
"<c:ttytddphone>425-555-1120</c:ttytddphone>" & _
"<c:callbackphone>425-555-1121</c:callbackphone>"
' Specify the e-mail address information.
strEmailInfo = "<mapi:emaillisttype>1</mapi:emaillisttype>" & _
"<mapi:email1addrtype>EX</mapi:email1addrtype>" & _
"<mapi:email1emailaddress>" & _
"/o=Microsoft/ou=First Administrative
Group/cn=Recipients/cn=jdoe" & _
"</mapi:email1emailaddress>" & _
"<mapi:email1originaldisplayname>" & _
"John Doe (Exchange)" & _
"</mapi:email1originaldisplayname>" & _
"<mapi:email2addrtype>SMTP</mapi:email2addrtype>" & _
"<mapi:email2emailaddress>" & _
"(e-mail address removed)" & _
"</mapi:email2emailaddress>" & _
"<mapi:email2originaldisplayname>" & _
"John Doe (SMTP)" & _
"</mapi:email2originaldisplayname>" & _
"<mapi:email3addrtype>X400</mapi:email3addrtype>" & _
"<mapi:email3emailaddress>" & _
"c=us;a= ;p=Microsoft;o=Exchange;s=Doe;g=John;i=J;" & _
"</mapi:email3emailaddress>" & _
"<mapi:email3originaldisplayname>" & _
"John Doe (X400)" & _
"</mapi:email3originaldisplayname>"
' Specify organizational information.
' (Company, Company Main Phone, Business Home Page,
' Department, Job Title, Manager's Name,
' Assistant's Name, Assistant's Phone, Office Location,
' Organizational ID Number, Computer Network Name,
' Profession)
strOrganizationalInfo = "<c:eek:>Microsoft Corporation</c:eek:>" & _

"<c:eek:rganizationmainphone>425-882-8080</c:eek:rganizationmainphone>" & _

"<c:businesshomepage>http://www.microsoft.com</c:businesshomepage>" & _
"<c:department>YYY</c:department>" & _
"<c:title>Lead Software Design Engineer</c:title>" & _
"<c:manager>Ashley Doe</c:manager>" & _
"<c:secretarycn>Pat Doe</c:secretarycn>" & _
"<c:secretaryphone>425-555-1122</c:secretaryphone>" & _
"<c:roomnumber>C-309</c:roomnumber>" & _
"<c:employeenumber>987654321</c:employeenumber>" & _
"<c:computernetworkname>jdoe</c:computernetworkname>" & _
"<c:profession>Software Designer</c:profession>"
' Specify personal information.
' (Birthday, Anniversary, Spouse, Children, Gender,
' Personal Home Page, Hobbies)
strPersonalInfo = "<c:bday>1974-01-01T08:00:00Z</c:bday>" & _

"<c:weddinganniversary>1995-01-01T08:00:00Z</c:weddinganniversary>" & _
"<c:spousecn>Jane Doe</c:spousecn>" & _
"<c:childrensnames>" & _
"<x:v>Ellen Doe</x:v><x:v>Grace Doe</x:v>" & _
"</c:childrensnames>" & _
"<c:gender>Male</c:gender>" & _
"<c:personalHomePage>" & _
"http://www.homepagedomain.com/JohnDoe/default.htm" & _
"</c:personalHomePage>" & _
"<c:hobbies>Playing XBox games,Watching UltimateTV</c:hobbies>"
' Specify customer related information.
' (Customer ID, Account, Billing Information)
strCustomerInfo = "<c:customerid>YYY</c:customerid>" & _
"<c:account>YYY</c:account>" & _
"<c:billinginformation>YYY</c:billinginformation>" & _
"<c:contact>Test Comment</c:comment>"
' Specify Follow Up/Reminder information.
' (Reminder, Reminder Topic, Reminder Time, etc.)
strFollowUpInfo = "<mapi:reminderset>1</mapi:reminderset>" & _
"<mapi:request>Call</mapi:request>" & _
"<mapi:remindertime>2001-12-01T08:00:00Z</mapi:remindertime>" & _

"<mapi:remindernexttime>2001-12-01T08:00:00Z</mapi:remindernexttime>" & _
"<e:reply-by-iso>2001-12-01T08:00:00Z</e:reply-by-iso>"
' Specify miscellaneous information.
' (Categories, Contacts, Mileage, FTP Site, Language,
' Government ID, Location, Internet Free/Busy Address,
' Sensitivity)
strMiscInfo = "<e:keywords-utf8>" & _
"<x:v>Buddies</x:v><x:v>Engineers</x:v>" & _
"</e:keywords-utf8>" & _
"<mapi:contacts><x:v>Penelope Doe</x:v></mapi:contacts>" & _
"<e:mileage>Rarely used string property</e:mileage>" & _
"<c:ftpsite>ftp://ftp.microsoft.com/</c:ftpsite>" & _
"<c:language>US English</c:language>" & _
"<c:governmentid>000-00-0000</c:governmentid>" & _
"<c:location>Nowhere Land</c:location>" & _

"<cal:fburl>http://www.homepagedomain.com/JohnDoe/freebusy</cal:fburl>" & _
"<mapi:sensitivity>2</mapi:sensitivity>"
' Specify User Field information.
' (User Field 1, User Field 2, User Field 3, User Field 4)
strUserFieldsInfo = "<e:extensionattribute1>User Data 1" & _
"</e:extensionattribute1>" & _
"<e:extensionattribute2>User Data 2</e:extensionattribute2>" & _
"<e:extensionattribute3>User Data 3</e:extensionattribute3>" & _
"<e:extensionattribute4>User Data 4</e:extensionattribute4>"

' Put it all together in an HTTP request.
strBody = "<?xml version=""1.0""?>" & _
"<g:propertyupdate " & strXMLNSInfo & _
"<g:set>" & _
"<g:prop>" & _

"<g:contentclass>urn:content-classes:person</g:contentclass>" & _

"<e:eek:utlookmessageclass>IPM.Contact</e:eek:utlookmessageclass>" & _
strnameinfo & strbusinessaddrinfo & _
strHomeAddrInfo & strOtherAddrInfo & _
strMailAddrInfo & strPhoneInfo & _
strEmailInfo & strOrganizationalInfo & _
strPersonalInfo & strCustomerInfo & _
strFollowUpInfo & strMiscInfo & _
strUserFieldsInfo & _
"</g:prop>" & _
"</g:set>" & _
"</g:propertyupdate>"

' Open the request object, assigning it the method PROPPATCH
' objRequest.open("PROPPATCH", strURL, False, "UserName", "password")
objRequest.open("PROPPATCH",
"http://172.31.5.202/exchange/administrator/contacts/John Doe.eml", False,
"devdemo.local\administrator", "p@$$w0rd") '"omni\administrator",
"ic1ng0nthecak3?")
' Set the necessary headers for the request.
objRequest.setRequestHeader("Content-Type", "text/xml")
objRequest.setRequestHeader("Translate", "f")
objRequest.setRequestHeader("Content-Length", Len(strBody))

' Send the request, using the XML document as the body.
Try
objRequest.send(strBody)

Catch ex1 As System.Runtime.InteropServices.COMException
Return ex1.ToString
Catch ex2 As COMException
ex2.ToString()
Catch ex As Exception
Return ex.ToString
Finally

End Try

'Display the results.
If (objRequest.status >= 200 And objRequest.status < 300) Then
Return "Success! " & "Results = " & objRequest.status & _
": " & objRequest.statusText
ElseIf objRequest.status = 401 Then
Return "You don't have permission to do the job! " & _
"Please check your permissions on this item."
Else
Return "Request Failed. Results = " & objRequest.status & _
": " & objRequest.statusText
End If

objRequest = Nothing
 
K

Ken Slovak - [MVP - Outlook]

The notes field in WebDAV syntax is "urn:schemas:httpmail:textdescription",
in the Outlook object model it's ContactItem.Body.

A better place to post this would have been one of the Outlook or Exchange
programming newsgroups.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top