Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook Macro - Save Read mails

Status
Not open for further replies.

eilob

Programmer
Mar 28, 2007
54
IE
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!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top