![]() |
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. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
Perfect. Thanks very much.
I've noticed that if I have sent an e-mail to more than one recipient, then this code does not move the mail. Is there code you can help me with that will, in the event of there being more than one reipient, it will move the mail to the sub folder of the first person on the list (or a copy of the mail to the correct folder of every recipient, for which I have a sub subfolder) Thanks again. silverface. "Sue Mosher [MVP-Outlook]" wrote: Your code never accesses the Level 1 folder and therefore, can't locate its Level 1.1 subfolder. Set myInbox = myNameSpace.GetDefaultFolder(olFolderSentMail) Set myLevel1 = myInbox.Folders("Level 1") Set myDestFolder = myLevel1.Folders("Level 1.1") -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "S1lverface" wrote in message ... In my Sent Items I have a Subfolder called LEVEL 1. Below this I drill down to a sub subfolder called Level 1.1. I want the code below to move mail from Sent Items box to the Level 1.1 Folder but it doesn't find the folder, although it exists Can you help? Thanks S1lverface _________ Sub MoveSentItems() 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(olFolderSentMail) Set myItems = myInbox.Items Set myDestFolder = myInbox.Folders("Level 1.1") Set myItem = myItems.Find("[To] = 'John Brody'") While TypeName(myItem) "Nothing" myItem.Move myDestFolder Set myItem = myItems.FindNext Wend End Sub |
#2
|
|||
|
|||
![]()
That's because your code looks for an exact match:
Set myItem = myItems.Find("[To] = 'John Brody'" If you want to do something more complex, you can iterate the entire myItems collection and use Instr() to see if John Brody is present in the To field. Or, iterate the Recipients collection of each item. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "S1lverface" wrote in message ... Perfect. Thanks very much. I've noticed that if I have sent an e-mail to more than one recipient, then this code does not move the mail. Is there code you can help me with that will, in the event of there being more than one reipient, it will move the mail to the sub folder of the first person on the list (or a copy of the mail to the correct folder of every recipient, for which I have a sub subfolder) Thanks again. silverface. "Sue Mosher [MVP-Outlook]" wrote: Your code never accesses the Level 1 folder and therefore, can't locate its Level 1.1 subfolder. Set myInbox = myNameSpace.GetDefaultFolder(olFolderSentMail) Set myLevel1 = myInbox.Folders("Level 1") Set myDestFolder = myLevel1.Folders("Level 1.1") -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "S1lverface" wrote in message ... In my Sent Items I have a Subfolder called LEVEL 1. Below this I drill down to a sub subfolder called Level 1.1. I want the code below to move mail from Sent Items box to the Level 1.1 Folder but it doesn't find the folder, although it exists Can you help? Thanks S1lverface _________ Sub MoveSentItems() 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(olFolderSentMail) Set myItems = myInbox.Items Set myDestFolder = myInbox.Folders("Level 1.1") Set myItem = myItems.Find("[To] = 'John Brody'") While TypeName(myItem) "Nothing" myItem.Move myDestFolder Set myItem = myItems.FindNext Wend End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
How can I move a BUNCH of folders from one PST to another? | Bruce | Outlook and VBA | 0 | January 20th 08 08:52 PM |
How do you move OE folders from XP to Vista Windows Mail | Marty in GA | Outlook - General Queries | 1 | April 17th 07 04:34 PM |
How to Move Mail Folders Between Two Computers Running OE 6 | sheana | Outlook Express | 5 | November 26th 06 09:48 PM |
Macro to Move Mail Messages from Draft folder to other folders | VBnovice | Outlook and VBA | 4 | June 14th 06 07:10 PM |
How to move folders to another drive | Fred | Outlook Express | 6 | April 19th 06 09:42 PM |