Next I starting looking how to write a Macro for this. Thought this would be something easy to find. But no, found macros to delete, move, forward a single item at a time, forward selected item, rules. Nothing to forward the contents of a single folder as single email to another email.
So I started looking at the code for all this stuff. I’m not an outlook programmer but I do program with VBA in Microsoft Access. By no means am I great at it, but I get it and can usually read through and manipulate some code to get what I want. And that’s what I did here.
I found something that got me to select be able to select the folder that I wanted to work with (the Spam Folder), found something else that forwarded individual selected emails and processed them through a loop, and something else to delete items in a folder. After hours of frustration, I finally got it figured out.
I have seen similar questions asked but never did find the answer. As such, I hope this comes in handy for someone else.
If this has been what you were looking for, please leave a comment and let me know if it worked for you.
'Lookup how to set up the Developer Tab, Enable Macros,
'and Add to the Toolbar or Quick Access Toolbar.
'In the Outlook module copy and paste the
'following, updating your email address under msgAssassin.
Sub SpamAssassin()
Dim ns As NameSpace
Set ns = Application.GetNamespace("MAPI")
Set objJunk = ns.GetDefaultFolder(olFolderJunk).Items
'Assign the email address to forward items to
Dim msgAssassin As String
msgAssassin = "assp-spam@mydomain.com"
Dim objMail As Object
Dim objNewMail As Object
'Assign variable to delete items and assign the Junk E-mail folder
Dim i As Long
Dim objJunkFolder As Outlook.Folder
Dim objJunkMail As Outlook.Items
Set objJunkFolder = ns.GetDefaultFolder(olFolderJunk)
Set objJunkMail = objJunkFolder.Items
Set objNewMail = Application.CreateItem(olMailItem)
'Forward each item as attachment
For Each objMail In objJunk
objNewMail.Attachments.Add objMail
Next
'Delete item from Junk E-mail Folder
For i = objJunkMail.Count To 1 Step -1
objJunkMail.Remove i
Next
objNewMail.To = msgAssassin
objNewMail.Subject = "Reporting Items"
objNewMail.Display
Set objJunk = Nothing
Set objMail = Nothing
Set objNewMail = Nothing
End Sub