SOLVED

SOLVED - Disable Junk Folder

Iron Contributor

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.

 ProofOfDisabled.JPG

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

 

 

6 Replies
@Victor 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. :)

Hi @Kendethar,

 

you can easily adopt this flow for Outlook 365. 

@Victor Ivanidze

How would I apply this flow to Outlook 365?
best response confirmed by Kendethar (Iron Contributor)
Solution

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 Ivanidze 

 

Thank you for your post. I investigated and attempted your reply. I did have an issue.

PowerAutomate_Issue.png

This is because Power Automate is not included in my main Office 365 account.

 

Please read: But, I tested it with my licensed college outlook account, and I did not experience this issue. Furthermore, while signed into my college account, oddly I was able to connect my college account to the Office 365 Connector and my main account to the Outlook.com Connector, with no other way to configure each account/connector.

 

So, the "When a new email arrives (V3)" action only worked with my college account and the "... (V2)" action's only option was my main account. Was really strange. It seems that Power Automate only works with the account signed into it, or is otherwise ambiguous. Regardless, out of principle to whomever is reading this seeking a solution to their problem, please consider this simple list of pros:

 

 

 

My code's pros:                                                          Power Automate's pros:

- Message with details, if desired                               - User-friendly

- Applies to all the App's associated accounts           - Simple to use and understand

- More customizable to the user's specific needs      - Applies to all the user's associated devices

 

 

 

Concluding this attempt, unfortunately, this method did not help me. However, this is a FAR better solution than my code for the average Office tools user, being that Power Automate can manage at the server level (cloud flow), which will apply the junk folder action to all devices! Thank you! 

1 best response

Accepted Solutions
best response confirmed by Kendethar (Iron Contributor)
Solution

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

 

View solution in original post