outlook macro to move all emails to and from a recipient

phairplay

Active Member
Joined
Nov 2, 2011
Messages
260
could someone help me I would like a macro to move all email sent to and from a recipient into a sub folder, but only move read emails. so at a later date it will be easy to fine all in and outbound emails to that recipient.



many thanks
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Have you looked at using the Rules Wizard that should help you without thinking about VBA.
 
Upvote 0
I've relooked into rules

the problem is I can create a rule to move the inbox items but with the sent items it marks them all as unread

I've found the following for inbox items

Sub MoveItems3()
Dim myOlApp As New Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Dim myInbox As Outlook.MAPIFolder
Dim myDestFolder As Outlook.MAPIFolder
Dim myItems As Outlook.Items
Dim myItem As Object
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set myInbox = myNameSpace.GetDefaultFolder(olFolderInbox)
Set myItems = myInbox.Items
Set myDestFolder = myInbox.Folders("Sarah Attenborough")
Set myItem = myItems.Find("[SenderName] = 'Sarah Attenborough'")
While TypeName(myItem) <> "Nothing"
myItem.Move myDestFolder
Set myItem = myItems.FindNext
Wend
End Sub

now I would like one for sent TO items in the sent file to move them into the same inbox sub folder as above
 
Upvote 0
Hi There

This macro is almost what I am looking for but I want it to look up a name in the recipient field and then move that email to a specified folder.

I am really struggling particularly with Set myItem = myItems.Find("[SenderName] = 'Sarah Attenborough'")

 
Upvote 0

Forum statistics

Threads
1,225,619
Messages
6,186,050
Members
453,335
Latest member
sfd039

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top