Moving emails to another email account

K

kellyhell

I currently log onto Outlook using my personal account.

I also have access to a shared mailbox which is showing in my folde
list.

I have the following code which I cannot get to work. The bit I'm tryin
to sort out is the:

3. To move the item:
' NOTE: You need to first define olDestFolder

where would I define the olDestFolder?

TIA

Sub ProcessFolder(CurrentFolder As Outlook.MAPIFolder)

Dim i As Long
Dim olNewFolder As Outlook.MAPIFolder
Dim olDestFolder As Outlook.MAPIFolder
' late bind this object variable, since it could be various ite
types
Dim olTempItem As Object
' Set olNameSpace = olApp.GetNamespace("MAPI")


' Loop through the items in the current folder.
' Looping through backwards in case items are to be deleted,
' as this is the proper way to delete items in a collection.
For i = CurrentFolder.Items.count To 1 Step -1

Set olTempItem = CurrentFolder.Items(i)


' Check to see if a match is found
If InStr(1, olTempItem.Subject, strSearchString, 0) > 0 Then

' The following are examples of what you can do:
' 1. To notify that message was found:
'MsgBox "Found message with subject: " & olTempItem.Subject
'
' 2. To delete the item:
' olTempItem.Delete
'
'* 3. To move the item:
' NOTE: You need to first define olDestFolder
*


'olTempItem.Move olDestFolder

lCountOfFound = lCountOfFound + 1

End If

Next

' Loop through and search each subfolder of the current folder.
For Each olNewFolder In CurrentFolder.Folders

If olNewFolder.Name <> "Deleted Items" Then
ProcessFolder olNewFolder
End If

Next

End Su
 

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