Jump to content
PatV

GMail Inbox

Recommended Posts

Hi All,

 

I'm searching a way to remove the Tag 'Inbox' from message.

 

I try to send command, via    IdImap4.SendCmd('C1','UID STORE '+rMess.UID+' -X-GM-LABELS ("Inbox")',['OK','BAD','NO'], true);

Without success.

 

Any clues ?

 

Regards

 

Patrick

Share this post


Link to post
12 hours ago, PatV said:

I try to send command, via    IdImap4.SendCmd('C1','UID STORE '+rMess.UID+' -X-GM-LABELS ("Inbox")',['OK','BAD','NO'], true);

Without success.

Have you tried using \Inbox instead, as shown in GMail's IMAP Extensions documentation?

IdImap4.SendCmd('UID STORE ' + rMess.UID + ' -X-GM-LABELS (\Inbox)', ['OK','BAD','NO'], true);

That being said, why are you using the SendCmd() method manually?  TIdIMAP4 has a UIDStoreValue() method for sending a UID STORE command:

 

IdImap4.UIDStoreValue(rMess.UID, sdRemove, 'X-GM-LABELS', '\Inbox');

 

Share this post


Link to post

Hi Remy,

 

Thanks for your component and your support,

 

 

I've tried it also and get an error too. 

IdImap4.SendCmd('UID STORE ' + rMess.UID + ' -X-GM-LABELS (\Inbox)', ['OK','BAD','NO'], true);


S:C1 UID STORE  189  -X-GM-LABELS (\Inbox)

R:C1 BAD Could not parse command

 

IdImap4.UIDStoreValue(rMess.UID, sdRemove, 'X-GM-LABELS', '\Inbox');

I didn't look at this function, I'll go with it

 

Thanks

 

Patrick

 

Share this post


Link to post
7 hours ago, PatV said:

I've tried it also and get an error too. 


IdImap4.SendCmd('UID STORE ' + rMess.UID + ' -X-GM-LABELS (\Inbox)', ['OK','BAD','NO'], true);


S:C1 UID STORE  189  -X-GM-LABELS (\Inbox) 

R:C1 BAD Could not parse command

Looks like you have extra spaces surrounding the 189. Do you get the same error if you remove them?

 

Also, I found this, might be useful: How to remove a label from an email message from Gmail by using the IMAP protocol?

Share this post


Link to post

Hi Remy You are right about the extra spaces, I've got another message, now.

 

S:C1 UID STORE 193 -X-GM-LABELS (\Inbox)

R:C1 BAD UID STORE not allowed now.

 

If found also the link you mentioned How to remove a label from an email message from Gmail by using the IMAP protocol?

as this one too on witch you have replied.  what-belongs-in-aexpectedresponses-parameter-to-tidimap4-sendcmd

 

I've tried also the "move" command but I didn't get the good UID, my goal was to read messages header through RetrieveHeader, and move later message selected on a TVirtualStringTree, but It seems that once I close the imap connection, those uid are no more correct.

 

	  IDImap4.SelectMailBox('INBOX');
      IDImap4.SearchMailBox(aSearchInfo);
      iUID:=0;
      with IDImap4 do
        for i:=0 to High(MailBox.SearchResult) do
        begin
          iMsg:=TIdMessage.Create;
          iMsg.Clear;
          RetrieveHeader(MailBox.SearchResult[i],iMsg);
          sUID:=IntToStr(MailBox.SearchResult[i]);
          iUID:=MailBox.SearchResult[i];
          rMess.WithMessage(iMsg).WithUID(sUID).WithNode(Nil).asUnSelected;
          AnArray.add<rMsg>(Msgs,rMess);
        end;
      FillVST;
      IdIMap4.Disconnect;            

 

I'll test the function tomorrow.

IdImap4.UIDStoreValue(rMess.UID, sdRemove, 'X-GM-LABELS', '\Inbox');

Thanks again

 

Patrick


 

Share this post


Link to post
6 hours ago, PatV said:

Hi Remy You are right about the extra spaces, I've got another message, now.

 

S:C1 UID STORE 193 -X-GM-LABELS (\Inbox)

R:C1 BAD UID STORE not allowed now.

Sorry, I don't know what that means.

6 hours ago, PatV said:

It seems that once I close the imap connection, those uid are no more correct.

UIDs are unique within a given folder, but not necessarily across folders.  Multiple folders can refer to the same message.  And UIDs are persistent only so long as the folder's UIDValidity value doesn't change.  If you save a UID across sessions, you have to check if the folder's UIDValidity has changed before you can use the UID again.

 

When you select a folder with TIdIMAP4.SelectMailBox(), its current UIDValidity value is stored in the TIdIMAP4.MailBox.UIDValidity property.

 

Refer to RFC 3501 section 2.3.1.1 for more details.

6 hours ago, PatV said:

 


IDImap4.SearchMailBox(aSearchInfo);
...
RetrieveHeader(MailBox.SearchResult[i],iMsg);
sUID:=IntToStr(MailBox.SearchResult[i]);
iUID:=MailBox.SearchResult[i];
...

 

TIdIMAP4.SearchMailBox() returns message numbers, not UIDs.  If you want UIDs, use TIdIMAP4.UIDSearchMailBox() instead.

 

Otherwise, you can extract a UID from the result of TIdIMAP4.RetrieveHeader(), or pass message numbers from TIdIMAP4.SearchMailBox() to TIdIMAP4.GetUID().

Share this post


Link to post

Thanks a lot for the explanation Remy !

 

Patrick

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×