A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Moving emails to another email account



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old March 13th 12, 12:30 PM
kellyhell kellyhell is offline
Junior Member
 
First recorded activity at Outlookbanter: Oct 2010
Posts: 3
Default Moving emails to another email account

I currently log onto Outlook using my personal account.

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

I have the following code which I cannot get to work. The bit I'm trying 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 item 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 Sub
Ads
 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleted email account, where are the emails stored? Colin Lourdes Outlook - General Queries 1 April 18th 11 08:45 AM
Moving email account details when moving pst file efandango Outlook - Installation 3 July 21st 09 09:27 AM
Which Outlook email account when replying to emails? Lobster Outlook - General Queries 22 January 20th 09 01:39 PM
moving emails to folders based on sender email address Rudy L. Outlook and VBA 1 December 31st 08 01:14 PM
Moving Outlook account to another Windows log-in user account chillinnsatx Outlook - General Queries 6 July 20th 07 11:41 PM


All times are GMT +1. The time now is 05:01 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.