C
Clif Haugen
The following code works fine in Outlook 2000 and 2002. However, in
2003 the code runs fine but the next time Outlook is started it will
disable the VBA module.
I've tried to replace the .OTM file for the session and that hasn't
fixed the problem. I've also replaced all of my Outlook.Application
syntax with just Application. That hasn't worked. I've also looked
for any missing Set statements, but can't locate any.
The offending code is below. I can't claim to have created it - it
was posted in this newsgroup some time ago. I've made a few
modifications and find it very helpful for dealing with Junk Senders.
I would _really_ appreciate any thoughts!!
Clifford
Private Const JUNK_SENDERS_FILE As String = _
"C:\Documents and Settings\jim smartt\Application
Data\Microsoft\Outlook\Junk Senders.txt"
Public Sub MultipleJunkEMailSenders()
Dim objNS As NameSpace
Dim objApp As Application
Dim objExp As Explorer
Dim objMessage As Object
Dim objMailItem As MailItem
Dim objReply As MailItem
Dim objItems As Items
Dim objExplorer As Explorer
Dim intItem As Integer
Dim objFSO As Scripting.FileSystemObject
Dim objTextStream As Scripting.TextStream
Dim CPH As String
Set objApp = New Application
Set objNS = objApp.GetNamespace("MAPI")
Set objExp = objApp.ActiveExplorer
Set objFSO = New Scripting.FileSystemObject
If objFSO.FileExists(FileSpec:=JUNK_SENDERS_FILE) = False Then
Set objTextStream = objFSO.CreateTextFile _
(FileName:=JUNK_SENDERS_FILE)
Else
Set objTextStream = objFSO.OpenTextFile _
(FileName:=JUNK_SENDERS_FILE, IOMode:=ForAppending)
End If
Set objExplorer = Application.ActiveExplorer
For Each objMessage In objExplorer.Selection
Set objMailItem = objMessage
Set objReply = objMailItem.Reply
CPH = objReply.Recipients.Item(1).Address
objReply.Close olDiscard
objTextStream.WriteLine Text:=CPH
objMailItem.UnRead = True
objMailItem.Delete
Next objMessage
End Sub
2003 the code runs fine but the next time Outlook is started it will
disable the VBA module.
I've tried to replace the .OTM file for the session and that hasn't
fixed the problem. I've also replaced all of my Outlook.Application
syntax with just Application. That hasn't worked. I've also looked
for any missing Set statements, but can't locate any.
The offending code is below. I can't claim to have created it - it
was posted in this newsgroup some time ago. I've made a few
modifications and find it very helpful for dealing with Junk Senders.
I would _really_ appreciate any thoughts!!
Clifford
Private Const JUNK_SENDERS_FILE As String = _
"C:\Documents and Settings\jim smartt\Application
Data\Microsoft\Outlook\Junk Senders.txt"
Public Sub MultipleJunkEMailSenders()
Dim objNS As NameSpace
Dim objApp As Application
Dim objExp As Explorer
Dim objMessage As Object
Dim objMailItem As MailItem
Dim objReply As MailItem
Dim objItems As Items
Dim objExplorer As Explorer
Dim intItem As Integer
Dim objFSO As Scripting.FileSystemObject
Dim objTextStream As Scripting.TextStream
Dim CPH As String
Set objApp = New Application
Set objNS = objApp.GetNamespace("MAPI")
Set objExp = objApp.ActiveExplorer
Set objFSO = New Scripting.FileSystemObject
If objFSO.FileExists(FileSpec:=JUNK_SENDERS_FILE) = False Then
Set objTextStream = objFSO.CreateTextFile _
(FileName:=JUNK_SENDERS_FILE)
Else
Set objTextStream = objFSO.OpenTextFile _
(FileName:=JUNK_SENDERS_FILE, IOMode:=ForAppending)
End If
Set objExplorer = Application.ActiveExplorer
For Each objMessage In objExplorer.Selection
Set objMailItem = objMessage
Set objReply = objMailItem.Reply
CPH = objReply.Recipients.Item(1).Address
objReply.Close olDiscard
objTextStream.WriteLine Text:=CPH
objMailItem.UnRead = True
objMailItem.Delete
Next objMessage
End Sub