<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>VBA on MarkJacobsen.net</title><link>https://test.markjacobsen.net/tags/vba/</link><description>Recent content in VBA on MarkJacobsen.net</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Wed, 10 Apr 2013 12:22:39 +0000</lastBuildDate><atom:link href="https://test.markjacobsen.net/tags/vba/index.xml" rel="self" type="application/rss+xml"/><item><title>Outlook Macros to Categorize and Archive Messages</title><link>https://test.markjacobsen.net/2013/04/outlook-macros-to-categorize-and-archive-messages/</link><pubDate>Wed, 10 Apr 2013 12:22:39 +0000</pubDate><guid>https://test.markjacobsen.net/2013/04/outlook-macros-to-categorize-and-archive-messages/</guid><description>&lt;p&gt;If you’re still rockin’ Outlook 2007 and want to create some macros to categorize or archive your email, here’s some copy and paste code to have fun with…&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Sub Archive()
 Call CommonCategorizeAndArchive(True, False, False)
End Sub

Sub Categorize()
 Call CommonCategorizeAndArchive(False, True, False)
End Sub

Sub CategorizeAndArchive()
 Call CommonCategorizeAndArchive(True, True, False)
End Sub

Sub Task()
 Call CommonCategorizeAndArchive(True, True, True)
End Sub

Private Sub CommonCategorizeAndArchive(archiveEm As Boolean, categorizeEm As Boolean, taskIt As Boolean)
 Dim olApp As New Outlook.Application
 Dim olItem As Object
 Dim olExp As Outlook.Explorer
 Dim olSel As Outlook.Selection
 Dim olArchive As Outlook.Folder
 Dim olTasks As Outlook.Folder
 Dim olNameSpace As Outlook.NameSpace
 Dim olTmpMailItem As Outlook.MailItem
 
 Set olExp = olApp.ActiveExplorer
 Set olSel = olExp.Selection
 Set olNameSpace = olApp.GetNamespace(&amp;quot;MAPI&amp;quot;)
 
 Set olArchive = olNameSpace.GetDefaultFolder(olFolderInbox).Folders(&amp;quot;@Archive&amp;quot;)
 Set olTasks = olNameSpace.GetDefaultFolder(olFolderInbox).Folders(&amp;quot;zTasks&amp;quot;)

 For intItem = 1 To olSel.Count
 Set olItem = olSel.Item(intItem)
 olItem.UnRead = False
 
 If (categorizeEm = True) Then
 olItem.ShowCategoriesDialog
 End If
 
 If (archiveEm = True) Then
 olItem.Move olArchive
 End If
 
 If (taskIt = True) Then
 Set olTmpMailItem = olItem.Copy
 olTmpMailItem.Move olTasks
 End If
 Next intItem
End Sub
&lt;/code&gt;&lt;/pre&gt;</description></item></channel></rss>