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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook 2000 Visual Basic Macro Help!

Status
Not open for further replies.

F8i

Programmer
Apr 23, 2001
1
GB
Hi!
I am looking for some code to check all 'NewMail' that enters the inbox of outlook. On checking it then 'Saves Out' each MailItem as a txt file with the subject field as the file name. Does anyone have any ideas on why this piece of code below doesnt work:
----------------------------------------------
Dim WithEvents myOlApp As Outlook.Application
----------------------------------------------
Sub Initialize_handler()
Set myOlApp = CreateObject("Outlook.application")
End Sub
----------------------------------------------
Private Sub myOlApp_NewMail()
Dim myExplorers As Outlook.Explorers
Dim myFolder As Outlook.MAPIFolder
Set myExplorers = myOlApp.Explorers
Set myFolder = myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
If myExplorers.Count <> 0 Then
For x = 1 To myExplorers.Count
On Error GoTo skipif
If myExplorers.Item(x).CurrentFolder.Name = &quot;Inbox&quot; Then
myExplorers.Item(x).Display
myExplorers.Item(x).Activate
Set myItem = myOlApp.ActiveInspector.CurrentItem
myItem.SaveAs &quot;C:\Point Of Contact\FaxLogs\&quot; & myItem.Subject & &quot;.txt&quot;, 0
Exit Sub
End If
skipif:
Next x
End If
On Error GoTo 0
myFolder.Display
End Sub
----------------------------------------------
If anyone has any ideas it would be greatly appreciated!
Thanks!
Liam North
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top