Search code examples
vbaemailoutlookoutlook-2010

Outlook 2010 Force Update UI after MailItem.MarkAsTask


I have a script that runs when I receive an email with a certain subject. At the end of the script I want to mark the MailItem as complete and have it show the checkmark next to the email.

I call MarkAsTask olMarkComplete which does what it's supposed to but the UI doesn't update and the checkmark doesn't appear unless I select/deselect the email through the UI

Edit: When I loop through all emails in my folder it only works on the last one set. Am I missing something here..?

My code so far:

Dim reviewFolder As Folder
Dim item As Outlook.MailItem

Set myFolder = ThisOutlookSession.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Folders("My Folder")

For Each item In myFolder.Items
    {other code}
    item.MarkAsTask olMarkComplete
Next

Solution

  • You need to call MailItem.Save.