View Full Version : Automatically add flag and reminder for ME on sent message in Outlook
MrDrease
09-15-2022, 06:07 AM
Hello,
I'm trying to automatically add flag and reminder for myself on sent messages in Outlook.
I've found and tried numerous codes and even non-VBA solutions to flag outgoing messages for follow-up and add a reminder. But the problem is that the flag gets appended to the outgoing message and thus arrives at the recipient's side.
Rather I'm looking for a way to not change anything for the recipient; but just add a reminder on my own outlook sent item.
The code might have to listen to the action of a new item arriving in the sent folder.
Can this be done?
Thank you for any help!
georgiboy
09-15-2022, 08:10 AM
Perhaps something like:
Option Explicit
Private WithEvents inboxItems As Outlook.Items
Private Sub Application_Startup()
Dim outlookApp As Outlook.Application: Set outlookApp = Outlook.Application
Dim objectNS As Outlook.NameSpace: Set objectNS = outlookApp.GetNamespace("MAPI")
Dim ShrdRecip As Outlook.Recipient: Set ShrdRecip = objectNS.CreateRecipient("someone@somewhere.com")
Set inboxItems = objectNS.GetSharedDefaultFolder(ShrdRecip, olFolderInbox).Parent.Folders("Sent Items").Items
End Sub
Private Sub inboxItems_ItemAdd(ByVal Item As Object)
If InStr(UCase(Item.Body), "HI") > 0 Then
Item.FlagRequest = "Follow up"
Item.FlagDueBy = DateAdd("d", 2, Date)
End If
End Sub
MrDrease
09-16-2022, 04:39 AM
Thank you for your reply Georgiboy!
I pasted your example code in ThisOutlookSession; and updated your "someone[AT]somewhere.com" to my email address.
I then sent a test email to some other address making sure it contained "HI" in the body
But nothing really happened regarding follow-up flags or reminders or tasks on the message.
I don't know what I'm doing wrong.
Thanks again!
georgiboy
09-16-2022, 04:42 AM
After you paste in the code try closing outlook and then reopen. The flag should be attached to the item in the sent folder.
MrDrease
09-16-2022, 04:57 AM
After you paste in the code try closing outlook and then reopen. The flag should be attached to the item in the sent folder.
Hi again.
Sorry, no effect yet.
Have you tried it with yours? Does it work with you?
I would be very willing to send some screenshots of how it is set up etc if requested
thanks again
georgiboy
09-16-2022, 07:17 AM
Ahh I think I should have added in the Item.Save part:
Option Explicit
Private WithEvents inboxItems As Outlook.Items
Private Sub Application_Startup()
Dim outlookApp As Outlook.Application: Set outlookApp = Outlook.Application
Dim objectNS As Outlook.NameSpace: Set objectNS = outlookApp.GetNamespace("MAPI")
Dim ShrdRecip As Outlook.Recipient: Set ShrdRecip = objectNS.CreateRecipient("g.clark@maritimetransport.com")
Set inboxItems = objectNS.GetSharedDefaultFolder(ShrdRecip, olFolderInbox).Parent.Folders("Sent Items").Items
End Sub
Private Sub inboxItems_ItemAdd(ByVal Item As Object)
Dim tmp As String
With Item
If InStr(UCase(.Body), "HI") > 0 Then
.FlagRequest = "Follow up"
.FlagDueBy = Format(DateAdd("d", 2, Date) + TimeValue("18:00:00"), "dd/mm/yyyy hh:mm")
.Save
End If
End With
End Sub
MrDrease
09-19-2022, 01:08 AM
Hello again,
Sadly it's still not working. I did try closing outlook and restarting it, but I still don't see any reminders or tasks.
georgiboy
09-19-2022, 11:25 PM
Hmm, I am not sure, will have to have a think.
Is the name of your 'Sent Items' folder different in Belgium?
Could try updating that in the code if it is different.
MrDrease
09-20-2022, 01:50 AM
Hi Georgiboy,
It usually is when it's in Dutch, but I'm running an English version of Office.
Have you tested it on your side? Does a new task just just pop-up in your tasks list?
arnelgp
09-20-2022, 02:17 AM
there are some codes here:
How to set a flag to follow up using VBA (slipstick.com) (https://www.slipstick.com/developer/code-samples/set-flag-follow-up-using-vba/)
MrDrease
09-20-2022, 04:10 AM
Okay I think we might have to drop it. I'm starting to suspect it's my employer ICT department having blocked Macros in Outlook as a group security policy or something. :banghead: Never got an error message or anything though.
I'm so sorry to have wasted your time! :(:(
georgiboy
09-20-2022, 04:14 AM
Hi Georgiboy,
It usually is when it's in Dutch, but I'm running an English version of Office.
Have you tested it on your side? Does a new task just just pop-up in your tasks list?
I was only checking the mail in the outbox to see if it had a flag on it.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.