Hello Yahya,
I would say yes but I'm new to this. I've spent over a month trying to
figure this out.
I'm not sure what you mean by "Differen public folder trees". Are you
asking if it will copy items between public folders in different stores?
If
so, I would say the answer is yes because I'm copying message items
between
the exchange store and the public folder store.
Also, all it does is go out to a user folder. I.e.
http://exchangeserver/exchange/user I then I set my query to return all
message items in all folders for that user with the following query.
strQuery = "<?xml version=\"1.0\"?><D:searchrequest xmlns:D = \"DAV:\" >"
+
"<D:sql>SELECT \"DAV:displayname\", ,\"DAV:creationdate\",
\"DAV:parentname\"" +
" FROM scope('DEEP TRAVERSAL OF \"" + strSourceURI + "\"')" +
"WHERE \"DAV:ishidden\" = false AND \"DAV:contentclass\" =
'urn:content-classes:message'" +
"</D:sql></D:searchrequest>";
I then take the a:href which is a url to the file and make another call in
the code you have to that file which returns an xml dump of the contents
of
the file. In the public store folder I create a new item and take the xml
dump from the orignal message from the private store and place it in the
new
item in the public folder. So it shouldn't matter what folders you are
copying between.
To break it down a little simpler, I'm getting a stream to an existing
file
and then getting an xml dump of the file. Then creating a new item in a
different folder and taking that xml data and populating the item and it
then
displays the same as the original just in a different folder. Note, I was
having problems getting contact items to come across and show as contact
items versus notes in the new folder but I quite working on it because of
the
createdate problem I mentioned earlier.
If send me your email address I can send you the source file with what I
did.
"Yahya Saad" wrote:
Dear Kfrost,
Using the attached code can I copy or move items between different
public folder trees?
Thanks,
Yahya
"kfrost" <kfrost@discussions.microsoft.com> wrote in message
news:37745CDE-F2B2-42B9-822F-C97549AE742A@microsoft.com...
Hello Tom,
I disagree with you here. First off, you can do this inside outlook
so I
would think there would be a way to programmatically do this.
Also, I figured out a way to do this with WebDav. You go out an get
a
link
to the message you want to copy. You then open the item and get a xml
dump
of it's contents. Then you create a new item in the different store
and
dump
the xml data into it. It works great for me. The problem I have is
the
create date on the new items is when you create them. So all the new
items
will have a create date of when you create them which is causing me
problems
because that field is read-only. This is a show stopper for me so I'm
looking through the OOM and CDO for a way to do this.
Here's the part of my code that actually copies messages from a
private
store to a public store. (FYI, use the Exchange Explorer in the e2k3
sdk
to
get the urls and properties in testing.) I'm going to post my
question in
another thread.
public void CreateItem(string strSrcURI, string strDestURI)
{
MSXML2.XMLHTTP30 oXMLHttp = new MSXML2.XMLHTTP30();
MSXML2.XMLHTTP30 oXMLHttpPut = new MSXML2.XMLHTTP30();
// string strSrcURI =
"http://server/exchange/johndoe/cabinet/dvdxcopy/FW:%20test%20Activation%20c
rack.eml";
// string strDestURI =
"http://server/public/n-sv/deletedusers/johndoe/FW:%20test%20Activation%20cr
ack.eml";
try
{// Go out and get a stream for the following item
oXMLHttp.open("GET", strSrcURI, false, "", "");
oXMLHttp.setRequestHeader("Translate", "f");
oXMLHttp.setRequestHeader("Content-Type", "message/rfc822");
oXMLHttp.send(Missing.Value);
// Send the GET method request and get the
// response from the server.
/* Only use this in troubleshooting
Console.Write(oXMLHttp.status);
Console.Write(oXMLHttp.statusText);
Console.Write(oXMLHttp.responseText);
*/
// Check to see the return status. 200 or 201 means success.
if(oXMLHttp.status != 201 && oXMLHttp.status != 200 && oXMLHttp.status
!= 207)
{
DisplayError("Error occurrd in CreateItem from the Get function. URI =
" + strSrcURI + " Error Status " + oXMLHttp.status + " Status Text " +
oXMLHttp.statusText +
" ResponseText " + oXMLHttp.responseText);
return;
}
/* LEFT OF HERE. NEED TO FIGURE OUT HOW TO CREATE THE CONTACT IN
PROPER
FORMAT
*/
// Write stream received to new file in the destination folder
oXMLHttpPut.open("PUT", strDestURI, false, "", "");
oXMLHttpPut.setRequestHeader("Translate", "f");
// Commenting out to try and get contacts to be written correctly
// oXMLHttpPut.setRequestHeader("Content-Type", "message/rfc822");
// Console.WriteLine(oXMLHttp.responseText);
oXMLHttpPut.send(oXMLHttp.responseText);
int statusPut = (int) oXMLHttpPut.status;
if(oXMLHttpPut.status != 201 && oXMLHttpPut.status != 200)
DisplayError("Error occurrd in CreateItem from the PUT function. URI =
Error Status " + oXMLHttpPut.status + " Status Text " +
oXMLHttpPut.statusText +
" ResponseText " + oXMLHttpPut.responseText);
}
catch(Exception ex)
{
// Catch any exceptions. Any error codes from the GET
// method request on the server will be caught here, also.
DisplayError("Exception in CreateItem() : " + ex.Message);
}
}