Last active
December 1, 2021 20:58
-
-
Save tdalon/166c0542ef6d205dd1f8d271f83cfe58 to your computer and use it in GitHub Desktop.
Mark Emails Read and Complete with VBA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Sub Done() | |
Dim Items As VBA.Collection | |
Dim oItem As Object | |
Set Items = GetCurrentItems | |
For Each oItem In Items | |
If TypeOf oItem Is Outlook.MailItem Then | |
oItem.MarkAsTask (olMarkComplete) | |
oItem.UnRead = False | |
oItem.Save | |
End If | |
Next | |
End Sub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function GetCurrentItems() As VBA.Collection | |
Dim c As VBA.Collection | |
Dim Sel As Outlook.Selection | |
Dim obj As Object | |
Dim i& | |
Set c = New VBA.Collection | |
If TypeOf Application.ActiveWindow Is Outlook.Inspector Then | |
c.Add Application.ActiveInspector.CurrentItem | |
Else | |
Set Sel = Application.ActiveExplorer.Selection | |
If Not Sel Is Nothing Then | |
For i = 1 To Sel.Count | |
c.Add Sel(i) | |
Next | |
End If | |
End If | |
Set GetCurrentItems = c | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment