Search code examples
delphiimapdelphi-7indyindy10

How can I set a message unread?? with delphi 7 and imap from indy10


How can I set a email message unread??

Here I read the emails from inbox in gmail

When I read gmail, it flag like read, so I would like to flag like unread again.

 TheImap.GetUID(i+1, TheUID);
 TheImap.UIDRetrieveFlags(TheUID, TheFlags);
 TheImap.UIDRetrieveHeader(TheUID, TheMsg);
 TheImap.UIDRetrieveText(TheUID, lacadena);

 if mfSeen in TheFlags then begin
   TheImap.StoreFlags(TheUID, sdReplace, TheMsg.Flags - [mfSeen] );

Solution

  • You are trying to pass a UID string where a MsgNum integer is expected. You need to use UIDStoreFlags() instead of StoreFlags():

    TheImap.UIDStoreFlags(TheUID, sdReplace, TheFlags - [mfSeen]);