acpete48317
New Member
- Outlook version
- Outlook 2010 32 bit
- Email Account
- Exchange Server
I am new to programming in VBA and very new to Outlook VBA. I am trying to figure out how to apply an existing category in Outlook 2010 32 bit along with it's colored box as well as move that email to a folder in my Inbox. So far, I have the below code to move the currently selected email. Can anyone help with the category part of it? I am stumped.
Sub moveMail()
Dim objOutlook As Outlook.Application
Dim objNamespace As Outlook.NameSpace
Dim objSourceFolder As Outlook.MAPIFolder
Dim objDestFolder As Outlook.MAPIFolder
Dim objItem As Object
Set objOutlook = Application
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objSourceFolder = objNamespace.GetDefaultFolder(olFolderDrafts)
Set objItem = objOutlook.ActiveExplorer.Selection.Item(1)
Set objDestFolder = objNamespace.Folders("Adam.son@a.gov").Folders("CA")
'Change "CA" to the correct name in the outlook folder
'Change ""Adam.son@a.gov" and "CA" to refer to PST folder
objItem.Move objDestFolder
' Set all objects equal to Nothing to destroy them and
' release the memory and resources they take.
Set objDestFolder = Nothing
Set objOutlook = Nothing
Set objNamespace = Nothing
Set objSourceFolder = Nothing
Set objItem = Nothing
End Sub
Also, does anyone know of any background reading that would help with the theory of VBA?
Sub moveMail()
Dim objOutlook As Outlook.Application
Dim objNamespace As Outlook.NameSpace
Dim objSourceFolder As Outlook.MAPIFolder
Dim objDestFolder As Outlook.MAPIFolder
Dim objItem As Object
Set objOutlook = Application
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objSourceFolder = objNamespace.GetDefaultFolder(olFolderDrafts)
Set objItem = objOutlook.ActiveExplorer.Selection.Item(1)
Set objDestFolder = objNamespace.Folders("Adam.son@a.gov").Folders("CA")
'Change "CA" to the correct name in the outlook folder
'Change ""Adam.son@a.gov" and "CA" to refer to PST folder
objItem.Move objDestFolder
' Set all objects equal to Nothing to destroy them and
' release the memory and resources they take.
Set objDestFolder = Nothing
Set objOutlook = Nothing
Set objNamespace = Nothing
Set objSourceFolder = Nothing
Set objItem = Nothing
End Sub
Also, does anyone know of any background reading that would help with the theory of VBA?