PDA

View Full Version : Accessing Public Folders in MS Exchange


gklandes
03-27-2009, 05:54 PM
I've created some simple apps using the <cfexchangeconnection> tools and that works great for getting mail, cal, tasks ... etc. from exchange for a specific user.

Does anyone know how to get calendar items from a "Public Folder" exchange?

My research has revealed that it is likely going to involve a webdav connection, but I haven't seen many details.

vimal2071987
12-21-2009, 01:18 PM
hello friends.....
need ur help...
i m accessing public folder of MS Exchange via OWA
how to add mails,contacts,tasks,appointment programatically?
Right now m using HTTP for post items in public folder but there is some problem with URI....

code snipet of adding contact is as follow............
please reply as soon as possible....
thanx in advance....


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;

namespace PublicFolderContacts
{
class Program
{
static void Main(string[] args)
{
try
{
// TODO: Replace with the URL of an object on the computer that is running Exchange 2000.
string sUri = "http://localhost/public/vimalcontacts/";

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

string strXMLNSInfo;
string strNameInfo;
/

// 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:\">";

strNameInfo = "<c:givenName>vimal</c:givenName>" +
"<c:middlename>kantilal</c:middlename>" +
"<c:sn>raghwani</c:sn>" +
"<c:cn>vimal kantilal raghwani</c:cn>" +
"<mail:subject>vimal raghwani</mail:subject>" +
"<c:fileas>raghwani, vimal</c:fileas>" +
"<c:initials>JJD</c:initials>" +
"<c:nickname>vim</c:nickname>" +
"<c:personaltitle>Mrs.</c:personaltitle>" +
"<c:namesuffix>Msc.tech</c:namesuffix>";
// Specify the Business Address Information.
// (Street, PO Box, City, State, Postal Code, and Country)


string sQuery;
sQuery = "<?xml version='1.0'?>" +
"<g:propertyupdate>" + strXMLNSInfo +
"<g:set>" +
"<g:prop>" +
"<g:contentclass>urn:content-classes:person</g:contentclass>" +
"<e:outlookmessageclass>IPM.Contact</e:outlookmessageclass>" +
strNameInfo /*+ strBusinessAddrInfo +
strHomeAddrInfo +strOtherAddrInfo +
strMailAddrInfo + strPhoneInfo +
strEmailInfo + strOrganizationalInfo +
strPersonalInfo + strCustomerInfo +
strFollowUpInfo + strMiscInfo +
strUserFieldsInfo */ +
"</g:prop>" +
"</g:set>" +
"</g:propertyupdate>";

// Set the credentials.

NetworkCredential myCred = new NetworkCredential("vimal", "Exchange_12345");
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.Headers.Set("Translate", "f");
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.ASCII.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();
Console.WriteLine("Status Code: {0}", sStatus);
// Get the request headers
string sReqHeaders = HttpWRequest.Headers.ToString();
Console.WriteLine(sReqHeaders);

// Read the Response Steam
Stream strm = HttpWResponse.GetResponseStream();
StreamReader sr = new StreamReader(strm);
string sText = sr.ReadToEnd();
Console.WriteLine("Response: {0}", sText);

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

// Clean up
myCred = null;
myCredentialCache = null;
HttpWRequest = null;
HttpWResponse = null;
QueryStream = null;
strm = null;
sr = null;
}
catch (Exception e)
{
Console.WriteLine("{0} Exception caught.", e);
}

}
}
}

Gjslick
12-21-2009, 11:58 PM
This is the ColdFusion forum, you're going to want to post that under the asp.net forum. And wrap your code with code tags when posting.