|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Moving mail items from a Public Folder to a General Purpose FolderFolders to be able to assign search folders on that general purpose folder. I am using the following code: '********************************************************** ' Variables. Dim strSrcURL Dim strDestURL Dim strUserName Dim strPassword Dim req strSrcURL = "http://dar-tempvp.exchtemp.com/public/folder1/" strDestURL = "http://dar-tempvp.exchtemp.com/general/folder1/" strUserName = "Domain\administrator" strPassword = "password" ' Initialize the XMLHTTP request object. Set req = CreateObject("Microsoft.xmlhttp") ' Open the request object with the MOVE method and ' specify that it will be sent asynchronously. req.Open "COPY", strSrcURL, False, strUserName, strPassword ' Set the Destination header to the destination URL. req.setRequestHeader "Destination", strDestURL 'Send the MOVE method request. req.Send ' An error occurred on the server. If req.Status >= 500 Then MsgBox "Status: " & req.Status MsgBox "Status text: An error occurred on the server." Else MsgBox "Status: " & req.Status MsgBox "Status text: " & req.StatusText End If '********************************************************** I am receiving this error 502 (Bad Gateway): The COPY destination is located on a different server, which refuses to accept the resource. although they reside on the same server. But when I apply that code to copy items from Public Folder to another Public Folder or to copy items from General Purpose Folder to another General Purpose Folder the copy succeds. How can I copy items between Public Folders and General Purpose Folders? Regards, Yahya You can't copy between stores. I assume general purpose you either mean
mailbox folders or another public folder tree. Tom -- Show quoteHide quoteLooking for a good book on programming Exchange, Outlook, ADSI and SharePoint? Check out http://www.microsoft.com/MSPress/books/5517.asp "Yahya Saad" <yahyas***@hotmail.com> wrote in message news:ehyc$w80EHA.2156@TK2MSFTNGP10.phx.gbl... >I am trying to copy mail items from Public Folders to General Purpose > Folders to be able to assign search folders on that general purpose > folder. > > I am using the following code: > > '********************************************************** > ' Variables. > Dim strSrcURL > Dim strDestURL > Dim strUserName > Dim strPassword > Dim req > > strSrcURL = "http://dar-tempvp.exchtemp.com/public/folder1/" > strDestURL = "http://dar-tempvp.exchtemp.com/general/folder1/" > strUserName = "Domain\administrator" > strPassword = "password" > > ' Initialize the XMLHTTP request object. > Set req = CreateObject("Microsoft.xmlhttp") > > ' Open the request object with the MOVE method and > ' specify that it will be sent asynchronously. > req.Open "COPY", strSrcURL, False, strUserName, strPassword > > ' Set the Destination header to the destination URL. > req.setRequestHeader "Destination", strDestURL > > 'Send the MOVE method request. > req.Send > > ' An error occurred on the server. > If req.Status >= 500 Then > MsgBox "Status: " & req.Status > MsgBox "Status text: An error occurred on the server." > > Else > MsgBox "Status: " & req.Status > MsgBox "Status text: " & req.StatusText > End If > '********************************************************** > > I am receiving this error 502 (Bad Gateway): The COPY destination is > located > on a different server, which refuses to accept the resource. > although they reside on the same server. > > But when I apply that code to copy items from Public Folder to another > Public Folder or to copy items from General Purpose Folder to another > General Purpose Folder the copy succeds. > > How can I copy items between Public Folders and General Purpose Folders? > > Regards, > Yahya > > > Yes I mean another public folder tree.
Thanks Yahya Show quoteHide quote "Tom Rizzo [MSFT]" <thom***@microsoft.com> wrote in message news:ewgJcqx1EHA.3816@TK2MSFTNGP09.phx.gbl... > You can't copy between stores. I assume general purpose you either mean > mailbox folders or another public folder tree. > > Tom > > -- > Looking for a good book on programming Exchange, Outlook, ADSI and > SharePoint? Check out http://www.microsoft.com/MSPress/books/5517.asp > > > > "Yahya Saad" <yahyas***@hotmail.com> wrote in message > news:ehyc$w80EHA.2156@TK2MSFTNGP10.phx.gbl... > >I am trying to copy mail items from Public Folders to General Purpose > > Folders to be able to assign search folders on that general purpose > > folder. > > > > I am using the following code: > > > > '********************************************************** > > ' Variables. > > Dim strSrcURL > > Dim strDestURL > > Dim strUserName > > Dim strPassword > > Dim req > > > > strSrcURL = "http://dar-tempvp.exchtemp.com/public/folder1/" > > strDestURL = "http://dar-tempvp.exchtemp.com/general/folder1/" > > strUserName = "Domain\administrator" > > strPassword = "password" > > > > ' Initialize the XMLHTTP request object. > > Set req = CreateObject("Microsoft.xmlhttp") > > > > ' Open the request object with the MOVE method and > > ' specify that it will be sent asynchronously. > > req.Open "COPY", strSrcURL, False, strUserName, strPassword > > > > ' Set the Destination header to the destination URL. > > req.setRequestHeader "Destination", strDestURL > > > > 'Send the MOVE method request. > > req.Send > > > > ' An error occurred on the server. > > If req.Status >= 500 Then > > MsgBox "Status: " & req.Status > > MsgBox "Status text: An error occurred on the server." > > > > Else > > MsgBox "Status: " & req.Status > > MsgBox "Status text: " & req.StatusText > > End If > > '********************************************************** > > > > I am receiving this error 502 (Bad Gateway): The COPY destination is > > located > > on a different server, which refuses to accept the resource. > > although they reside on the same server. > > > > But when I apply that code to copy items from Public Folder to another > > Public Folder or to copy items from General Purpose Folder to another > > General Purpose Folder the copy succeds. > > > > How can I copy items between Public Folders and General Purpose Folders? > > > > Regards, > > Yahya > > > > > > > > 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%20crack.eml"; // string strDestURI = "http://server/public/n-sv/deletedusers/johndoe/FW:%20test%20Activation%20crack.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); } } Dear Kfrost,
Using the attached code can I copy or move items between different public folder trees? Thanks, Yahya Show quoteHide quote "kfrost" <kfr***@discussions.microsoft.com> wrote in message "http://server/exchange/johndoe/cabinet/dvdxcopy/FW:%20test%20Activation%20cnews: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 = > rack.eml"; > // string strDestURI = "http://server/public/n-sv/deletedusers/johndoe/FW:%20test%20Activation%20cr> ack.eml"; Show quoteHide quote > > 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); > } > } 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. Show quoteHide quote "Yahya Saad" wrote: > Dear Kfrost, > > Using the attached code can I copy or move items between different > public folder trees? > > Thanks, > Yahya > > > "kfrost" <kfr***@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); > > } > > } > > > Dear Kfrost,
I am very sorry for my late response since I were very busy with other issues, kindly send me the source file to copy items between public folders in different stores. Thank you, Yahya Show quoteHide quote "kfrost" <kfr***@discussions.microsoft.com> wrote in message "http://server/exchange/johndoe/cabinet/dvdxcopy/FW:%20test%20Activation%20cnews:F46D366C-83C8-45D5-AF42-E17DF9E5EC0E@microsoft.com... > 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" <kfr***@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 = > > > > > > > rack.eml"; "http://server/public/n-sv/deletedusers/johndoe/FW:%20test%20Activation%20cr> > > // string strDestURI = > > > > > Show quoteHide quote > > 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); > > > } > > > } > > > > > >
Other interesting topics
Delete Message in Save Event Sink
Create recurring appointment with cdo Respond to meeting request using WebDAV Combined Resource calendar view - where to start Categories de/activate EventSinks by User again BCC Meeting organizers and the "on behalf of" trick How can I get Query based distribution lists? Votting buttons |
|||||||||||||||||||||||