I need to save into a folder a copy of every email read..
I have created a macro in Outlook and I was testing my code but is not saving them, the name of the folder is Read Mail and is a subfolder of the inbox..
I saved the code in the This Outlook Session and then if I restart outlook should work but doesnt..
If anyone have any idea.. here is my code
Private Function Item_Close()
Dim objNS
Dim objMainFolder 'The target .pst folder
Dim objTargetFolder 'The target sub-folder for saving the item
Dim objNewItem 'The item to be moved to target sub-folder
' m_blnOpenInsp = False
'MsgBox "Form is closing"
On Error Resume Next
Set objNS = Application.GetNamespace("MAPI")
Set objMainFolder = objNS.GetDefaultFolder(olFolderInbox).Items
Set objTargetFolder = objMainFolder.Folders.Item("Mail Read")
Set objNewItem = Item.Copy
objNewItem.Move objTargetFolder
Set objMainFolder = Nothing
Set objTargetFolder = Nothing
Set objNewItem = Nothing
End Function
THANKSS!
I have created a macro in Outlook and I was testing my code but is not saving them, the name of the folder is Read Mail and is a subfolder of the inbox..
I saved the code in the This Outlook Session and then if I restart outlook should work but doesnt..
If anyone have any idea.. here is my code
Private Function Item_Close()
Dim objNS
Dim objMainFolder 'The target .pst folder
Dim objTargetFolder 'The target sub-folder for saving the item
Dim objNewItem 'The item to be moved to target sub-folder
' m_blnOpenInsp = False
'MsgBox "Form is closing"
On Error Resume Next
Set objNS = Application.GetNamespace("MAPI")
Set objMainFolder = objNS.GetDefaultFolder(olFolderInbox).Items
Set objTargetFolder = objMainFolder.Folders.Item("Mail Read")
Set objNewItem = Item.Copy
objNewItem.Move objTargetFolder
Set objMainFolder = Nothing
Set objTargetFolder = Nothing
Set objNewItem = Nothing
End Function
THANKSS!