Forum Discussion
SOLVED - Disable Junk Folder
Hello,
I had a persisting issue of important E-mails going into my junk folder, under my nose, causing a couple instances of trouble at my job. I turned off automatic filtering but it made absolutely no difference. The lowest level of auto filtering stated it would still send blocked senders to my junk folder but I have very few senders that are blocked and the E-mails that Outlook would send to junk were from people at work who had never E-mailed me before.
Of course, there is always a need for junk folders. We all know those pesky insurance companies that you got a quote from once then using their unsubscribe is seemingly vain. My spam folder has and is always just the domains I listed to go to it, and nothing else - has never given me issues, unlike junk. So, I researched a fix to this issue to no avail. I then tried to delete or disable the junk folder but it is a default folder of Outlook, so not possible. So, I looked into VBA and came up with code from researching varying sources.
This is what I came up with, posted for anyone else that may have this issue. If there is an easier way and/or suggestions to improve the code further, please let me know.
Private Sub Application_ItemLoad(ByVal Item As Object)
Call Disable_JunkFolder
'Note: This sub will run on application startup.
End Sub
Sub Disable_JunkFolder()
'''ENABLE THIS CODE:
'Click the File tab > Options > Trust Center > Trust Center Settings > Macro Settings > select _
"Enable all macros" > OK > OK
'''APPLY THIS CODE:
'Click the File tab > Options > Customize Ribbon > Under "Customize the Classic Ribbon" and under "Main Tabs", _
select the "Developer" check box > OK > click the Developer tab > Visual Basic > select "ThisOutlookSession" > _
paste all this code > at the top left of the code window, click the "Save VbaProject.OTM" button (Ctrl+S)
'''DISABLE THIS CODE:
'Remove single quotation mark in front of "Exit Sub" (add symbol back to re-enable) or permanently delete all _
this code then save.
'Exit Sub
Dim Folder_Inbox As Outlook.Folder
Dim Folder_Junk As Outlook.Folder
Dim Outlook_EmailAccount As Outlook.Store
Dim Notification_Item_All As String, Notification_Acc As String, Noted_Acc_Count As Integer
Notification_Item_All = "Recovered the E-mail(s): """
Noted_Acc_Count = 0
On Error Resume Next
For Each Outlook_EmailAccount In Application.Session.Stores
Set Folder_Inbox = Outlook_EmailAccount.GetDefaultFolder(olFolderInbox)
Set Folder_Junk = Outlook_EmailAccount.GetDefaultFolder(olFolderJunk)
While InStr(Folder_Junk, "Spam") = False And Folder_Junk.Items.Count <> 0
'While InStr(Folder_Junk, "Junk") And Folder_Junk.Items.Count <> 0 '(Can be used instead)
For Each Item In Folder_Junk.Items
If Notification_Item_All = "Recovered the E-mail(s): """ Then
Notification_Item_All = Notification_Item_All & Item.Subject & """"
Else: Notification_Item_All = Notification_Item_All & ", """ & Item.Subject & """"
End If
If InStr(Notification_Acc, Outlook_EmailAccount) = False Then
If Noted_Acc_Count = 0 Then
Noted_Acc_Count = Noted_Acc_Count + 1: Notification_Acc = Outlook_EmailAccount
Else: Notification_Acc = Notification_Acc & ", " & Outlook_EmailAccount
End If: End If
Item.Move Folder_Inbox
Next
Wend
Next
If Notification_Item_All <> "Recovered the E-mail(s): """ Then
Notification_Item_All = Notification_Item_All & " from the junk folder in: " & Notification_Acc
MsgBox Notification_Item_All, vbInformation, "Microsoft Outlook - E-mail Recovery": End If '(Can disable this MsgBox with single quotation mark)
'Note: This code does not include any spam folder.
'Note: This code applies to all associated accounts saved within the Outlook Application.
'''Code credit:
'Kenneth Nelson
'https://techcommunity.microsoft.com/t5/outlook/solved-disable-junk-folder/m-p/3281531
'''Original code credits:
'https://stackoverflow.com/questions/47992801/vba-move-mail-from-junk-to-inbox
'https://stackoverflow.com/questions/38191434/switching-between-accounts-then-looping-through-email
'https://docs.microsoft.com/en-us/office/vba/api/outlook.oldefaultfolders
'https://docs.microsoft.com/en-us/office/vba/api/outlook.mailitem.subject
End Sub
Just change the trigger and the action to the same ones from the "Office 365 Outlook" connector.
I'll publish the version of "FromJunkToInbox" for Outlook 365 next week.See https://www.ivasoft.com/fromjunktoinboxflow365.shtml
- Victor_IvanidzeBronze ContributorHave a look at this: https://www.ivasoft.com/fromjunktoinboxflow.shtml
- KendetharIron ContributorVictor Ivanidze
I do not believe this will apply to any associated Outlook accounts other than Outlook.com. And, I use Outlook 365. But, a great solution for Outlook.com users! Thanks. 🙂- Victor_IvanidzeBronze Contributor