Hello,
We currently have a macro on our Outlook here at work that prompts the user to select a folder to save a sent item in a selected folder each time they click send. I didn't write this code and i have to confess that I know nothing about VBA in Outlook (I'm more of an Excel man).
I have been asked to see if I can change the macro so that as well as saving the sent item in the selected folder, a copy is also placed in the sent items folder so that people can easily view a list of all items sent.
Can anyone please tell me what needs to be added to this code in order to achieve this:
Dim WithEvents colSentItems As Items
Private Sub Application_Startup()
Dim ns As Outlook.NameSpace
Set ns = Application.GetNamespace("MAPI")
' Set event handler on the sent items folder to monitor when new items are saved to the folder
Set colSentItems = ns.GetDefaultFolder(olFolderSentMail).Items
Set ns = Nothing
End Sub
Private Sub colSentItems_ItemAdd(ByVal Item As Object)
Dim objNS As NameSpace
Dim objFolder As MAPIFolder
' This is fired every time an item is added to the Sent Items Folder
If Item.Class = olMail Then
' Only do this if the item is a sent email, ignore meeting requests etc.
Set objNS = Application.GetNamespace("MAPI")
Set objFolder = objNS.PickFolder
Do While objFolder Is Nothing
Set objFolder = objNS.PickFolder
Loop
If TypeName(objFolder) = "MAPIFolder" Then
If Not objFolder = objNS.GetDefaultFolder(olFolderSentMail) Then
' move email to the selected folder
Item.Move objFolder
End If
End If
Set objFolder = Nothing
Set objNS = Nothing
End If
End Sub
Thanks