HOW CAN I CHANGE THIS TO SENT ITEMS

Status
Not open for further replies.

SiSept

New Member
Outlook version
Outlook 2007
Email Account
Exchange Server
How can I change this to run on sent items?

Sub Test()

Dim ns As Outlook.NameSpace
Dim objItem As Object
Dim FolderInbox As Folder
Dim MyItem As Outlook.MailItem

'// Added - A collection to hold the IDs of message to be deleted
Dim cMAILS As Collection

Set ns = Application.GetNamespace("MAPI")
Set FolderInbox = ns.GetDefaultFolder(olFolderInbox)
Set cMAILS = New Collection

For Each objItem In FolderInbox.Items

'// You need one block for each category...
If InStr(objItem.Categories, "SMT AGENDA") > 0 Then
Set MyItem = objItem.Copy
MyItem.Move FolderInbox.Folders("AGENDAS 01 SMT")
cMAILS.Add objItem.EntryID

ElseIf InStr(objItem.Categories, "SMT TEAM LEADERS") > 0 Then
Set MyItem = objItem.Copy
MyItem.Move FolderInbox.Folders("AGENDAS 02 TEAM LEADERS MEETING")
cMAILS.Add objItem.EntryID

ElseIf InStr(objItem.Categories, "COMMUNICATION") > 0 Then
Set MyItem = objItem.Copy
MyItem.Move FolderInbox.Folders("AGENDAS 03 COMMUNICATION MEETING")
cMAILS.Add objItem.EntryID

ElseIf InStr(objItem.Categories, "CAROL MAITLAND") > 0 Then
Set MyItem = objItem.Copy
MyItem.Move FolderInbox.Folders("AGENDAS 04 CAROL MAITLAND")
cMAILS.Add objItem.EntryID

ElseIf InStr(objItem.Categories, "MANAGEMENT") > 0 Then
Set MyItem = objItem.Copy
MyItem.Move FolderInbox.Folders("AGENDAS 05 MANAGEMENT")
cMAILS.Add objItem.EntryID

ElseIf InStr(objItem.Categories, "ADP SUPPORT TEAM") > 0 Then
Set MyItem = objItem.Copy
MyItem.Move FolderInbox.Folders("PROJECTS 01 ADP")
cMAILS.Add objItem.EntryID

ElseIf InStr(objItem.Categories, "BBV") > 0 Then
Set MyItem = objItem.Copy
MyItem.Move FolderInbox.Folders("PROJECTS 02 BBV")
cMAILS.Add objItem.EntryID

ElseIf InStr(objItem.Categories, "CHILDRENS SERVICES") > 0 Then
Set MyItem = objItem.Copy
MyItem.Move FolderInbox.Folders("PROJECTS 03 CPC CHILDRENS SERVICES")
cMAILS.Add objItem.EntryID

ElseIf InStr(objItem.Categories, "D&I") > 0 Then
Set MyItem = objItem.Copy
MyItem.Move FolderInbox.Folders("PROJECTS 04 D&I")
cMAILS.Add objItem.EntryID

ElseIf InStr(objItem.Categories, "EARLIER INTERVENTION") > 0 Then
Set MyItem = objItem.Copy
MyItem.Move FolderInbox.Folders("PROJECTS 05 DIRECT ACCESS")
cMAILS.Add objItem.EntryID

ElseIf InStr(objItem.Categories, "FINANCE") > 0 Then
Set MyItem = objItem.Copy
MyItem.Move FolderInbox.Folders("PROJECTS 06 FINANCE")
cMAILS.Add objItem.EntryID

ElseIf InStr(objItem.Categories, "IAS") > 0 Then
Set MyItem = objItem.Copy
MyItem.Move FolderInbox.Folders("PROJECTS 07 IAS REDESIGN")
cMAILS.Add objItem.EntryID

ElseIf InStr(objItem.Categories, "KEEPWELL") > 0 Then
Set MyItem = objItem.Copy
MyItem.Move FolderInbox.Folders("PROJECTS 08 KEEPWELL")
cMAILS.Add objItem.EntryID

ElseIf InStr(objItem.Categories, "KEY PRIORITY") > 0 Then
Set MyItem = objItem.Copy
MyItem.Move FolderInbox.Folders("PROJECTS 09 KEY AIM AND NALOXONE")
cMAILS.Add objItem.EntryID

ElseIf InStr(objItem.Categories, "MARYWELL") > 0 Then
Set MyItem = objItem.Copy
MyItem.Move FolderInbox.Folders("PROJECTS 10 MARYWELL")
cMAILS.Add objItem.EntryID

ElseIf InStr(objItem.Categories, "PFR") > 0 Then
Set MyItem = objItem.Copy
MyItem.Move FolderInbox.Folders("PROJECTS 11 PFR")
cMAILS.Add objItem.EntryID

ElseIf InStr(objItem.Categories, "QUALITY FRAMEWORK") > 0 Then
Set MyItem = objItem.Copy
MyItem.Move FolderInbox.Folders("PROJECTS 12 QUALITY FRAMEWORK")
cMAILS.Add objItem.EntryID

ElseIf InStr(objItem.Categories, "RECOVERY") > 0 Then
Set MyItem = objItem.Copy
MyItem.Move FolderInbox.Folders("PROJECTS 13 RECOVERY")
cMAILS.Add objItem.EntryID

End If
Next
On Error Resume Next

Do While cMAILS.count > 0

Set MyItem = ns.GetItemFromID(cMAILS(1))

If Not MyItem Is Nothing Then
MyItem.Delete
End If

cMAILS.Remove (1)
Loop

End Sub
 

SiSept

New Member
Outlook version
Outlook 2007
Email Account
Exchange Server
This : Set FolderInbox = ns.GetDefaultFolder(olFolderInbox) needs changed to use olFolderSentItems
Thank you for replying asI am sure you are very busy. (sorry for the CAPS in the Heading - nothing meant by them!) I tried your suggested change and it wont work - the debug just highlights this line. I have no VBA knowledge!
[DOUBLEPOST=1443532347][/DOUBLEPOST]
See the GetDefaultFolder function, there change the passed value to olFolderSentItems.
Thank you for replying as I am sure you are very busy. (sorry for the CAPS in the Heading - nothing meant by them!) I tried your suggested change and it wont work - the debug just highlights this line. I have no VBA knowledge!
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
C Change default "Save Sent Item To" folder Outlook VBA and Custom Forms 9
C Change the default sent folder Outlook VBA and Custom Forms 1
D Change To address when it is sent to a specific address during specfic time. Using Outlook 2
J Bullet points change when sent Using Outlook 2
R suddenly I cannot open jpg pictures that are sent as attachments.....what do I need to reset or change to allow something to open up the pictures Using Outlook 3
e_a_g_l_e_p_i Outlook 2010 How can I change the font size on right side appointment pane Using Outlook 12
diver864 vba for a rule to automatically accept meeting requests with 'vacation' in subject, change to all-day event, change to free, don't send reply Outlook VBA and Custom Forms 1
B Change Font and Font size using VBA Outlook VBA and Custom Forms 9
D Change senders title Using Outlook 1
W Recurrence: delete older occurrences / change earliest start time Outlook VBA and Custom Forms 0
E Change sending account depending on Subjectline Outlook VBA and Custom Forms 0
J Outlook 2013 Change color of text in data fields of contacts in Outlook 2013? Using Outlook 3
B Change row background color of selected item Using Outlook 1
PGSystemTester VBA To Change AppointmentItem.BusyStatus From MeetingItem Before Send Using Outlook 0
B Change from Address Outlook VBA and Custom Forms 0
X If you change expiration date of repeated task it dupplicates Using Outlook 1
E How to display "Change Folder" in Change Default Email Delivery Location in Exchange Outlook 2016 Using Outlook 1
B See "Change View" Drop Down as a List? Using Outlook 1
V Change start time based on message duration Outlook VBA and Custom Forms 2
R Folder pane width change Using Outlook 59
S Change VBA script to send HTML email instead of text Outlook VBA and Custom Forms 3
S Outlook 2010 unable to change default font Using Outlook 7
P How can I change my calendar view back Using Outlook 3
A Edit subject - and change conversationTopic - using VBA and redemption Outlook VBA and Custom Forms 2
T Change the selected Message in the Outlook window Outlook VBA and Custom Forms 2
geofferyh How to change the Attachment File Name? Outlook VBA and Custom Forms 1
W Appointment occurrences change the location property Using Outlook 0
T Scheduled footer change Using Outlook 2
B Change font of reminder of an email header Outlook VBA and Custom Forms 3
CWM030 Name Change? Exchange Server Administration 9
V not able to change name in customize Ribbon Outlook VBA and Custom Forms 1
JoeG Appointment Delete/Change Recurrence Outlook VBA and Custom Forms 0
C Change Subject Line in Selected Emails Outlook VBA and Custom Forms 1
V Change default default save location to Quick Access Using Outlook 1
S Example VBA Macro - To Conditionally Change the From Account and Add a BCC Address on Emails Outlook VBA and Custom Forms 11
B Do not change the From address in Outlook Templates Using Outlook 0
M Sudden change in From field - now very short Using Outlook 4
M cannot change delivery folders with IMAP accounts Using Outlook 0
S Email Format With Embedded Images and Tables Change Using Outlook 2
O On click,I want to change subject line of selected mail and then reply to particular email and move Using Outlook 3
P Change PC User Directory & iPhone Sync Using Outlook 2
A Change order of actions in one (!) rule Outlook VBA and Custom Forms 2
I change subject and forward without FW: Outlook VBA and Custom Forms 4
Rupert Dragwater Can't change font size Using Outlook 5
M VBA to change flag status in outlook contact item Outlook VBA and Custom Forms 3
J Auto Forward - Include Attachment and change Subject depending on original sender Outlook VBA and Custom Forms 3
tjd189 outlook 2016 name change Using Outlook 1
E Button to change subject Outlook VBA and Custom Forms 1
K Paste from Windows Clipboard then change font without losing formatting Outlook VBA and Custom Forms 1
D Office365 Conference Room name change? Using Outlook 5
Similar threads


















































Top