| Author |  | 
      
        | hmuscroft Groupie
 
  
 
 Joined: 29 December 2009
 Location: United Kingdom
 Online Status: Offline
 Posts: 72
 | 
          Hi - I've (finally) finished integrating Gmail OAuth 2 into my WinForms desktop application and have spent several weeks jumping through all the hoops Google keep throwing at me - mainly involving making videos demonstrating my app working with Gmail.
           | Posted: 28 January 2021 at 2:13am | IP Logged |   |  
           | 
 |  
 Now they've asked me to demonstrate (in a video) my app deleting emails from the Gmail TRASH folder, showing that this also deletes them on Gmail (i.e. in a web browser).
 
 The weird thing is... it doesn't!
 
 So in my app, I call .SelectFolder("[Gmail]/Trash"), then I can read the emails and delete them from the Trash folder.
 
 In my app they have now GONE. If I re-read all the emails in the Gmail Trash folder, they've disappeared - as expected. Great. HOWEVER... they're all still there in the Gmail.com web browser.
 
 It seems that deleting emails from GMAIL TRASH via IMAP actually does NOT get rid of them.
 
 Have you come across this before please? Do you know what GMAIL does with emails once they're deleted from the TRASH folder? Do they go somewhere else or get flagged differently so that the MAILBEE.NET IMAP component doesn't see them any more?
 
 Any idea how to delete emails from the Gmail Trash folder?
 
 Many thanks for your help!
 
 Kind Regards,
 
 Hedley
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | hmuscroft Groupie
 
  
 
 Joined: 29 December 2009
 Location: United Kingdom
 Online Status: Offline
 Posts: 72
 | 
          OK, I think I can answer this myself.
           | Posted: 28 January 2021 at 2:56am | IP Logged |   |  
           | 
 |  
 Stepping through the code, I was ONLY calling IMAP.DeleteMessages(...).
 
 For most servers, calling this on an email in the TRASH folder seems to permanently delete it. With Gmail it doesn't - although goodness knows where it puts it?!
 
 I needed to call IMAP.DeleteMessages(...) followed by IMAP.Expunge(...) to permanently delete messages from the trash.
 
 Please can you confirm that this is correct?
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Igor AfterLogic Support
 
  
 
 Joined: 24 June 2008
 Location: United States
 Online Status: Offline
 Posts: 6168
 | 
          Yes that's right. To quote DeleteMessages method documentation page:
           | Posted: 28 January 2021 at 3:02am | IP Logged |   |  
           | 
 |  
 
 
| Quote: 
 
    
    | 
      
       | This method just sets "\Deleted" flag for the specified messages. To purge deleted messages permanently, call Expunge(String, Boolean) method or explicitly unselect the folder using Close(Boolean) method. |  |  |  
 --
 Regards,
 Igor, Afterlogic Support
 | 
       
        | Back to Top |     | 
       
       
        |  |