Thread: Automatic Flags
View Single Post
 
Old 08-07-2019, 11:21 PM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

You cannot flag a message until after it has been sent and appears in the Sent Items folder. You can intercept it there and choose whether to flag it using macros in the ThisOutlookSession folder of Outlook.

You will either have to run the macro Application_Startup manually or restart Outlook to run it. It then checks when items are added to the sent items folder, checks that they are messages and established whether they are already flagged or not. If not it will prompt to ask if you want to set a flag to the message with the subject and recipient named in the message, then either set a flag or not as chosen.

Code:
Option Explicit

Private WithEvents Items As Outlook.Items

Private Sub Application_Startup()
    SetItems
lbl_Exit:
    Exit Sub
End Sub

Public Sub SetItems()
    Set Items = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderSentMail).Items
lbl_Exit:
    Exit Sub
End Sub

Private Sub items_ItemAdd(ByVal Item As Object)
    If TypeName(Item) = "MailItem" Then
        If Not Item.IsMarkedAsTask = True Then
            If MsgBox("Subject: " & Item.Subject & vbCr & _
                      "To: " & Item.To & vbCr & vbCr & _
                      "Message is not flagged. Do you wish to flag the message?", vbYesNo) = vbYes Then
                Item.MarkAsTask olMarkNoDate
                Item.Save
            End If
        End If
    End If
lbl_Exit:
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote