-
Running a module on a loop
I am trying to create a way to capture all incoming emails (Outlook 2007) to a "customer support" inbox and save them to a folder on a network drive.
I have successfully used the code from the following KB article:
Save Emails From Outlook To Hard Drive
Now what I'd like to do is have this run on a loop so that any new incoming email will be added as well, including emails moved to subfolders.
Is there a way to do this?
Can this be done through Access by calling the procedure? (I'm thinking of creating a database to manage all of this).
Thank you.
-
Would you please post a link to the KB entry, I can't find it. If you cannot post a link just post the KB number.
-
It doesn't say what the article number is, but the number at the end of the link is kb_id=875
-
For reference here is the link: http://www.vbaexpress.com/kb/getarticle.php?kb_id=875
I think all you would need to do is use an event handler and call SaveAllEmails_ProcessAllSubFolders in it. Instead of using PickFolder, just point to the default Inbox.
ex:
[vba]
Private WithEvents Items As Outlook.Items
Private Sub Application_Startup()
Dim olApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Set olApp = Outlook.Application
Set objNS = olApp.GetNamespace("MAPI")
Set Items = objNS.GetDefaultFolder(olFolderInbox).Items
End Sub
Private Sub Items_ItemAdd(ByVal item As Object)
On Error Goto ErrorHandler
If TypeName(item) = "MailItem" Then
SaveAllEmails_ProcessAllSubFolders
End If
ProgramExit:
Exit Sub
ErrorHandler:
MsgBox Err.Number & " - " & Err.Description
Resume ProgramExit
End Sub
[/vba]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules