Rob
New Member
- OS Version(s)
- Windows
- Outlook version
- Outlook 2019 64-bit
- Email Account
- IMAP
Operating system:: Windows 11
Outlook version: Classic Outlook 2019
Email type or host: IMAP
Outlook version: Classic Outlook 2019
Email type or host: IMAP
Hi, I have a IMAP account for my inbox. I have a rule that moves all mail from that inbox to a folder in a separate .pst file. I then have other folders in the .pst file and code to add a task and a category to mail moved into those folders.
The problem comes when my code tries to save the changes to the MailItem. It is the 'can't save because has changed' error. It is not happening every time, but I would say 90% of the time I get the error.
All my google searches suggest it is a problem with IMAP taking too long to sync. But since the changes are happening in a .pst file and not the main IMAP file I am at a loss on what to do or how to prevent this error. Any advice on what I should try next?
The offending code, the 'Pause 2' is delay function that runs DoEvents every .1 of a second while delaying for the 2 seconds. Making it longer does not seem to help
catArray = Split(Item.Categories, ",")
If UBound(catArray) >= 0 Then
For i = 0 To UBound(catArray)
' Remove all the @ categories so no duplicates
If Left(Trim(catArray(i)), 1) = "@" Then
catArray(i) = ""
Item.Categories = Join(catArray, ",")
End If
Next
End If
Item.Categories = Category & "," & Item.Categories
Pause 2
Item.save
The problem comes when my code tries to save the changes to the MailItem. It is the 'can't save because has changed' error. It is not happening every time, but I would say 90% of the time I get the error.
All my google searches suggest it is a problem with IMAP taking too long to sync. But since the changes are happening in a .pst file and not the main IMAP file I am at a loss on what to do or how to prevent this error. Any advice on what I should try next?
The offending code, the 'Pause 2' is delay function that runs DoEvents every .1 of a second while delaying for the 2 seconds. Making it longer does not seem to help
catArray = Split(Item.Categories, ",")
If UBound(catArray) >= 0 Then
For i = 0 To UBound(catArray)
' Remove all the @ categories so no duplicates
If Left(Trim(catArray(i)), 1) = "@" Then
catArray(i) = ""
Item.Categories = Join(catArray, ",")
End If
Next
End If
Item.Categories = Category & "," & Item.Categories
Pause 2
Item.save