Reputation: 1483
How can I delete and flag messages in GMail with Delphi 10.3.3/stock Indy.
The following approach does not work (I ommitted the try/finally stuff to compress the code):
var
imap: TIdIMAP4;
msg: TIdMessage;
...
imap := TIdIMAP4.Create(nil);
...
if imap.SelectMailBox('INBOX') then
begin
for i := 1 to imap.MailBox.TotalMsgs do
begin
imap.Retrieve(i, msg);
imap.getUID(i, UID);
...
imap.UIDStoreFlags(UID, sdReplace, msg.Flags - [mfSeen]); -> DOESNT WORK
...
imap.UIDStoreFlags(UID, sdReplace, msg.Flags + [mfAnswered]); -> DOESNT WORK
...
imap.UIDDeleteMsg(UID); -> DOESNT WORK
...
end;
end;
...
imap.disconnect;
imap.free;
...
Is there any update statement that I omitted? Or do I need to set special settings within the gmail account?
UPDATE: Deletion now works but the flags are still not set. Deletion showed with a slight delay but the flags persist...
Upvotes: 0
Views: 1027
Reputation: 1483
Found the solutuion: My Impatience caused it.
It takes up to some minutes until the flag change is reflected in GMail. As I am constructing a forwarder running every 30s I will store the UIDs of seen messages of the last hour or so and take this list into account too.
Upvotes: 1