OL2007 - is there a way to disable the "feature" that cripples mails that are in the "junk" folder?

Status
Not open for further replies.

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
As long as junk mail is going into the junk e-mail folder in the default data file, it should get picked up and moved.

Use this as the application_startup code - see if this brings up the dialog when Outlook starts (or when you click in the app start macro) - the message box may come up behind the splash screen - click on the taskbar icon to find it.

Code:
 Private Sub Application_Startup()
 Dim oFolder as Outlook.folder
Set oFolder = Session.GetDefaultFolder(olFolderJunk)
 Set Items = oFolder.Items
 MsgBox "Watching... " & oFolder.Name
 End Sub

This is the full macro I'm using - it's the same as the one you posted, but without the annoying message box each time a message hits the junk folder. And it has the updated application startup.

Code:
Private WithEvents Items As Outlook.Items

Private Sub Application_Startup()
Dim oFolder As Outlook.folder
Set oFolder = Session.GetDefaultFolder(olFolderJunk)
Set Items = oFolder.Items
MsgBox "Watching... " & oFolder.Name
End Sub

Private Sub Items_ItemAdd(ByVal Item As Object)
' Set MovePst = Session.GetDefaultFolder(olFolderInbox).Parent.Folders("xPort\Zunk")
Set MovePst = GetFolderPath("xPort\Zunk")
Item.UnRead = False
Item.Move MovePst
End Sub

Function GetFolderPath(ByVal FolderPath As String) As Outlook.folder
Dim oFolder As Outlook.folder
Dim FoldersArray As Variant
Dim i As Integer

On Error GoTo GetFolderPath_Error
If Left(FolderPath, 2) = "\\" Then
FolderPath = Right(FolderPath, Len(FolderPath) - 2)
End If
'Convert folderpath to array
FoldersArray = Split(FolderPath, "\")
Set oFolder = Application.Session.Folders.Item(FoldersArray(0))
If Not oFolder Is Nothing Then
For i = 1 To UBound(FoldersArray, 1)
Dim SubFolders As Outlook.Folders
Set SubFolders = oFolder.Folders
Set oFolder = SubFolders.Item(FoldersArray(i))
If oFolder Is Nothing Then
Set GetFolderPath = Nothing
End If
Next
End If
'Return the oFolder
Set GetFolderPath = oFolder
Exit Function

GetFolderPath_Error:
Set GetFolderPath = Nothing
Exit Function
End Function
 

zdoe

Member
k. copied yours.

when i start OL, i don't see the "Watching..." message box. but i DO see it if i run that code snippet from VBA-editor.

e.g. - perhaps the startup macro doesn't run on start?

could the below have anything to do with this - the default mail file is somehow corrupt - mostly it works, but it doesn't let me compact it, and doesn't get fixed with the repair PST utility.

 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
What type of account is that? It really shouldn't matter...
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
That's what my test account is. I'm just not sure why you are getting that error message or if it's a factor in why this isn't working for you.
 

zdoe

Member
somehow i think that may be related to the code not working as the folders under the root on that file don't appear in the outlook folders list that i had posted above a few msgs back. but then Junk E-mail is anyway not a standard folder - which is why this whole thread exists !
 

zdoe

Member
hold on. it's WORKING after all !

not on mails that i manually move to Junk, but on newly arrived mails - which is the desired function anyway. just the startup notification does not appear.

the next improvement - how to flag the moved msgs unread in the ItemAdd -code snippet? i'd like to monitor on one glance how much junk has arrived.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Remove this line - Item.UnRead = False - or set it to true. This original purpose of this code was for sent items that were moved using a rule - they are marked Unread and it annoyed people.
 

zdoe

Member
k - removed that line. yes, that worked, i now get "unread" msgs @ \zunk.

but i was rejoicing too early - the macro only runs sometimes, not always. haven't been able to pin down what might be the rationale of that.

could it have something to do with the bug that displays the VBA editor?
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
No, I don't think so. It should run every time a message is dropped in the Junk mail folder. If the account was an exchange (and possibly outlook.com or imap), the macro could fail because the message is moved online, so Outlook doesn't see it being added. Another cause of failure is too many messages coming in at once.
 

zdoe

Member
however - it never ran/runs on messages that i move there manually, it sometimes now does on the incoming ones that come there from the outside mail server. no exchange, just a buncha pop3/smtp accounts. how to troubleshoot?
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
I've been thinking about it and don't understand why it's not running all the time.

Are you using separate data files? The macro only watches the junk folder in the default data file - if you have more than one that is used for delivery, the junk folder for those accounts is not going to be watched.
 

zdoe

Member
my junk folder is indeed in the default data file:
3/1/2015 5:02:12 PM: Selected Archive Name: CurrEmail
3/1/2015 5:02:12 PM: Total Number of Sub Folders: 10
3/1/2015 5:02:12 PM: \\CurrEmail\Deleted Items
3/1/2015 5:02:12 PM: \\CurrEmail\Contacts
3/1/2015 5:02:12 PM: \\CurrEmail\Drafts
3/1/2015 5:02:12 PM: \\CurrEmail\Inbox
3/1/2015 5:02:12 PM: \\CurrEmail\Junk E-mail
3/1/2015 5:02:12 PM: \\CurrEmail\Outbox
3/1/2015 5:02:12 PM: \\CurrEmail\Sent Items
3/1/2015 5:02:12 PM: \\CurrEmail\Calendar
3/1/2015 5:02:12 PM: \\CurrEmail\Tasks
3/1/2015 5:02:12 PM: \\CurrEmail\Notes

i'm still thinking that this could have something to do with the fact that "properties>advanced" is unavailable for the data file...
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Is the CurrEmail data file a pst? If not, what type of email account created it?
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Do you get any error messages when you try to use Properties > Advanced ? It should open a dialog but the dialog can vary.

Have you used scanpst on the data file?
 

zdoe

Member
the error message:

"The information service cannot be configured. Either the information service does not possess properties required for configuration, or the MAPI configuration file entry point could not be configured."

i run scanpst on the data file as a scheduled task every other night.
 
Status
Not open for further replies.
Top