Results 1 to 4 of 4

Thread: Need to move mail and calendar items from user folders to a

  1. #1
    kfrost Guest

    Need to move mail and calendar items from user folders to a

    Hello,

    First off I understand with webdav you can't use the copy methods to move or
    copy items to different stores. I did figure out a round about way to do
    this using webdav however, the biggest problem is that the I can't preserve
    the message date on the items. Since my program is technically creating new
    items in public folder and getting an xml dump from the original message.
    The create date is when the program is ran it's a read only property I can't
    manipulate. (I posted some of the code in the post "Moving mail items from a
    public folder to a General purpose folder.)

    So I'm looking for other ideas. You can do this in Outlook so to me that
    means it can be programmatically accomplished. However, looking through the
    OOM, I can't figure out how to go through and either get a collection of
    folders or setup a query that returns all mail items in all folders like you
    can with WebDav.

    I've started looking at CDO and have yet to come up with anything.

    Also, to help understand, my task is to take all a user's emails and
    appointments who has left a company and copy these to a public folder.

    Any ideas or pointers would be greatly appreciated.

  2. #2
    Glen Scales [MVP] Guest
    One mehod that may work is to use copyto in CDO 1.2 this does preserve the
    senttime. Eg I use this piece of code to copy items from a public folder to
    an inbox

    set objSession = CreateObject("MAPI.Session")
    strProfile = "Servername" & vbLf & "MailboxAlias"
    objSession.Logon "",,, False,, True, strProfile
    Set objInbox = objSession.Inbox
    Set objInfoStore = objSession.GetInfoStore(objSession.Inbox.StoreID)
    Set objpubstore = objSession.InfoStores("Public Folders")
    messid = "messageid"
    set objmessage = objSession.getmessage(messid,objpubStore.id)
    set objCopyMessage = objmessage.copyto(objInbox.ID,objInfoStore.ID)
    objCopyMessage.Update
    Set objCopyMessage = Nothing
    objsession.Logoff

    Cheers
    Glen


    "kfrost" <kfrost@discussions.microsoft.com> wrote in message
    news:B7D01B51-0351-459F-810A-B6866392DAEA@microsoft.com...
    Hello,

    First off I understand with webdav you can't use the copy methods to move
    or
    copy items to different stores. I did figure out a round about way to do
    this using webdav however, the biggest problem is that the I can't
    preserve
    the message date on the items. Since my program is technically creating
    new
    items in public folder and getting an xml dump from the original message.
    The create date is when the program is ran it's a read only property I
    can't
    manipulate. (I posted some of the code in the post "Moving mail items
    from a
    public folder to a General purpose folder.)

    So I'm looking for other ideas. You can do this in Outlook so to me that
    means it can be programmatically accomplished. However, looking through
    the
    OOM, I can't figure out how to go through and either get a collection of
    folders or setup a query that returns all mail items in all folders like
    you
    can with WebDav.

    I've started looking at CDO and have yet to come up with anything.

    Also, to help understand, my task is to take all a user's emails and
    appointments who has left a company and copy these to a public folder.

    Any ideas or pointers would be greatly appreciated.

  3. #3
    kfrost Guest
    Thanks Glen,

    I need to clarify a little more. If it were just getting items from the
    inbox I could figure that out. The problem I'm having is I need to copy all
    items in all folders. With CDO and OOM, it just appears you can either get
    items from one of the defined default folders such as inbox, calendar,
    contacts etc. The problem is you can create folders from the root or any
    where.

    Using web dav I can create a query and use the following code,

    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>";

    Can't seem to do that with the CDO or OOM. What I need is a way to either
    list all folders so I can traverse through them extracting the messages or
    like above have a way to filter different types of items from all folders for
    a user.

    I haven't found a way to do this in CDO or OOM.

    Thanks.

    kris


    "Glen Scales [MVP]" wrote:

    One mehod that may work is to use copyto in CDO 1.2 this does preserve the
    senttime. Eg I use this piece of code to copy items from a public folder to
    an inbox

    set objSession = CreateObject("MAPI.Session")
    strProfile = "Servername" & vbLf & "MailboxAlias"
    objSession.Logon "",,, False,, True, strProfile
    Set objInbox = objSession.Inbox
    Set objInfoStore = objSession.GetInfoStore(objSession.Inbox.StoreID)
    Set objpubstore = objSession.InfoStores("Public Folders")
    messid = "messageid"
    set objmessage = objSession.getmessage(messid,objpubStore.id)
    set objCopyMessage = objmessage.copyto(objInbox.ID,objInfoStore.ID)
    objCopyMessage.Update
    Set objCopyMessage = Nothing
    objsession.Logoff

    Cheers
    Glen


    "kfrost" <kfrost@discussions.microsoft.com> wrote in message
    news:B7D01B51-0351-459F-810A-B6866392DAEA@microsoft.com...
    Hello,

    First off I understand with webdav you can't use the copy methods to move
    or
    copy items to different stores. I did figure out a round about way to do
    this using webdav however, the biggest problem is that the I can't
    preserve
    the message date on the items. Since my program is technically creating
    new
    items in public folder and getting an xml dump from the original message.
    The create date is when the program is ran it's a read only property I
    can't
    manipulate. (I posted some of the code in the post "Moving mail items
    from a
    public folder to a General purpose folder.)

    So I'm looking for other ideas. You can do this in Outlook so to me that
    means it can be programmatically accomplished. However, looking through
    the
    OOM, I can't figure out how to go through and either get a collection of
    folders or setup a query that returns all mail items in all folders like
    you
    can with WebDav.

    I've started looking at CDO and have yet to come up with anything.

    Also, to help understand, my task is to take all a user's emails and
    appointments who has left a company and copy these to a public folder.

    Any ideas or pointers would be greatly appreciated.


  4. #4
    Glen Scales [MVP] Guest
    With CDO 1.2 its just a matter of looping though all the folder collections
    to get all the folders in a mailbox. You can then go though the messages
    collection of each folder to get at the particular messages you are after
    and you can also create filters if you want to (see www.cdolive.com for lots
    of good info on doing this). Eg the following will go though and list of the
    folders in a mailbox (including subfolders)

    set objSession = CreateObject("MAPI.Session")
    strProfile = "servername" & vbLf & "mailbox"
    objSession.Logon "",,, False,, True, strProfile
    Set objInfoStore = objSession.GetInfoStore(objSession.Inbox.StoreID)
    Set objTopFolder = objInfoStore.RootFolder
    Set CdoFolders = objTopFolder.Folders
    Set CdoFolder = CdoFolders.GetFirst
    do while Not (CdoFolder Is Nothing)
    wscript.echo CdoFolder.Name
    Set cdoSubFolders = CdoFolder.Folders
    If cdoSubFolders.count <> 0 Then checksubfolders(cdoSubFolders)
    Set CdoFolder = CdoFolders.GetNext
    loop

    sub checksubfolders(cdoSubFolders)

    Set CdoSubFolder = cdoSubFolders.GetFirst
    do while Not (CdoSubFolder Is Nothing)
    wscript.echo CdoSubFolder.Name
    Set cdoSubFolders1 = CdoSubFolder.Folders
    If cdoSubFolders1.count <> 0 Then checksubfolders(cdoSubFolders1)
    Set CdoSubFolder = cdoSubFolders.GetNext
    loop
    end sub

    Or if your more confortable using WebDAV and doing a SQL search of the
    exchange store you can combine both CDO and WebDAV. The only real trick is
    you need to include http://schemas.microsoft.com/mapi/proptag/x0FFF0102
    (PR_ENTRYID) in your query. This will return a bin.Base64 value back which
    you need to convert to hex to be able to use. To do this you can use
    ArrayConvert out of
    http://support.microsoft.com/default...b;en-us;250344 For example
    this will copy all the mail returned by the webdav query to a public folder.

    set objSession = CreateObject("MAPI.Session")
    strProfile = "servername" & vbLf & "mailboxname"
    objSession.Logon "",,, False,, True, strProfile
    Set objInbox = objSession.Inbox
    Set objInfoStore = objSession.GetInfoStore(objSession.Inbox.StoreID)
    Set objpubstore = objSession.InfoStores("Public Folders")
    set objtargetfolder = objSession.getfolder("PR_entryID(of
    folder)",objpubstore.id)


    server = "servername"
    mailbox = "mailbox"
    Set cnvt = CreateObject("ADs.ArrayConvert")
    strURL = "http://" & server & "/exchange/" & mailbox & "/inbox"
    strQuery = "<?xml version=""1.0""?><D:searchrequest xmlns:D = ""DAV:"" >"
    strQuery = strQuery & "<D:sql>SELECT ""DAV:href"",
    ""http://schemas.microsoft.com/mapi/proptag/x0FFF0102"" FROM scope('shallow
    traversal of """
    strQuery = strQuery & strURL & """') Where ""DAV:ishidden"" = False AND
    ""DAV:isfolder"" = False AND "
    strQuery = strQuery & """DAV:contentclass"" =
    'urn:content-classes:message'</D:sql></D:searchrequest>"
    set req = createobject("microsoft.xmlhttp")
    req.open "SEARCH", strURL, false
    req.setrequestheader "Content-Type", "text/xml"
    req.setRequestHeader "Translate","f"
    req.send strQuery
    If req.status >= 500 Then
    wscript.echo "Status: " & req.status
    wscript.echo "Status text: An error occurred on the server."
    ElseIf req.status = 207 Then
    wscript.echo "Status: " & req.status
    wscript.echo "Status text: " & req.statustext
    set oResponseDoc = req.responseXML
    set oNodeList = oResponseDoc.getElementsByTagName("d:x0FFF0102")
    For i = 0 To (oNodeList.length -1)
    set oNode = oNodeList.nextNode
    copymess(cnvt.CvOctetStr2vHexStr(oNode.nodeTypedVa lue))
    Next
    Else
    wscript.echo "Status: " & req.status
    wscript.echo "Status text: " & req.statustext
    wscript.echo "Response text: " & req.responsetext
    End If
    rem wscript.echo req.responsetext

    sub copymess(objmessid)
    set objmessage = objSession.getmessage(objmessid,objInfoStore.id)
    set objCopyMessage = objmessage.copyto(objtargetfolder.ID,objpubstore.I D)
    objCopyMessage.Update
    Set objCopyMessage = Nothing
    wscript.echo objmessid
    end sub

    Cheers
    Glen

    "kfrost" <kfrost@discussions.microsoft.com> wrote in message
    news:B1DD6548-68E1-4FB2-A637-827F93B020DB@microsoft.com...
    Thanks Glen,

    I need to clarify a little more. If it were just getting items from the
    inbox I could figure that out. The problem I'm having is I need to copy
    all
    items in all folders. With CDO and OOM, it just appears you can either
    get
    items from one of the defined default folders such as inbox, calendar,
    contacts etc. The problem is you can create folders from the root or any
    where.

    Using web dav I can create a query and use the following code,

    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>";

    Can't seem to do that with the CDO or OOM. What I need is a way to either
    list all folders so I can traverse through them extracting the messages or
    like above have a way to filter different types of items from all folders
    for
    a user.

    I haven't found a way to do this in CDO or OOM.

    Thanks.

    kris


    "Glen Scales [MVP]" wrote:

    One mehod that may work is to use copyto in CDO 1.2 this does preserve
    the
    senttime. Eg I use this piece of code to copy items from a public folder
    to
    an inbox

    set objSession = CreateObject("MAPI.Session")
    strProfile = "Servername" & vbLf & "MailboxAlias"
    objSession.Logon "",,, False,, True, strProfile
    Set objInbox = objSession.Inbox
    Set objInfoStore = objSession.GetInfoStore(objSession.Inbox.StoreID)
    Set objpubstore = objSession.InfoStores("Public Folders")
    messid = "messageid"
    set objmessage = objSession.getmessage(messid,objpubStore.id)
    set objCopyMessage = objmessage.copyto(objInbox.ID,objInfoStore.ID)
    objCopyMessage.Update
    Set objCopyMessage = Nothing
    objsession.Logoff

    Cheers
    Glen


    "kfrost" <kfrost@discussions.microsoft.com> wrote in message
    news:B7D01B51-0351-459F-810A-B6866392DAEA@microsoft.com...
    Hello,

    First off I understand with webdav you can't use the copy methods to
    move
    or
    copy items to different stores. I did figure out a round about way to
    do
    this using webdav however, the biggest problem is that the I can't
    preserve
    the message date on the items. Since my program is technically
    creating
    new
    items in public folder and getting an xml dump from the original
    message.
    The create date is when the program is ran it's a read only property I
    can't
    manipulate. (I posted some of the code in the post "Moving mail items
    from a
    public folder to a General purpose folder.)

    So I'm looking for other ideas. You can do this in Outlook so to me
    that
    means it can be programmatically accomplished. However, looking
    through
    the
    OOM, I can't figure out how to go through and either get a collection
    of
    folders or setup a query that returns all mail items in all folders
    like
    you
    can with WebDav.

    I've started looking at CDO and have yet to come up with anything.

    Also, to help understand, my task is to take all a user's emails and
    appointments who has left a company and copy these to a public folder.

    Any ideas or pointers would be greatly appreciated.


Similar Threads

  1. Replies: 3
    Last Post: 12-16-2005, 01:58 AM
  2. "auto" purging Deleted Items folders without user interventi
    By Robert Gordon in forum Administration
    Replies: 1
    Last Post: 12-12-2005, 05:58 PM
  3. move calendar from one user to another
    By Neil Jarman in forum Administration
    Replies: 4
    Last Post: 09-28-2005, 09:58 AM
  4. Replies: 7
    Last Post: 06-24-2005, 12:45 PM
  5. New user mail not configured after move
    By Marcus Armand in forum Deploy
    Replies: 1
    Last Post: 04-12-2005, 04:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other forums: Access Forum - Microsoft Office Forum - CAD Forum