| Author |  | 
      
        | loredano Newbie
 
  
  
 Joined: 11 April 2018
 Location: Italy
 Online Status: Offline
 Posts: 15
 | 
          Hi,
           | Posted: 04 October 2019 at 1:05am | IP Logged |   |  
           | 
 |  are there some difference between use the method
 
 public bool DeleteMessages(
 string messageIndexSet,
 bool indexIsUid
 )
 
 and/or
 
 public bool SetMessageFlags(
 string messageIndexSet,
 bool indexIsUid,
 SystemMessageFlags systemFlags,
 MessageFlagAction action
 )
 
 before to call  "Imap.Expunge Method" to permanently delete messages on imap server?
 
 This question because we note sometimes, with a large number of messages to delete, the messages are not deletes with not exceptions.
 In our code we use:
 imp.DeleteMessages(toDelete, true);
 imp.Expunge(toDelete, false)
 to delete the "toDelete" messages.
 
 
 Regards,
 Loredano
 
 
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Alex AfterLogic Support
 
  
  
 Joined: 19 November 2003
 Online Status: Offline
 Posts: 2207
 | 
          Hi,
           | Posted: 04 October 2019 at 1:36am | IP Logged |   |  
           | 
 |  
 You may try using imp.Expunge() without parameters if you want to delete all messages with \Deleted flag, not only certain ones.
 
 Anyway, the first troubleshooting measure is enabling log file (imp.Log). The log way show may actually happens there. Maybe, some issue with the mail server. Deleting lots of messages at once can be too heavy operation for that server and you may need to refactor the code to delete and expunge messages in smaller portions.
 
 Regards,
 Alex
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | ashrafaliimran Newbie
 
  
  
 Joined: 28 February 2025
 Location: Pakistan
 Online Status: Offline
 Posts: 1
 | 
          The main difference is that DeleteMessages marks messages for deletion, while SetMessageFlags allows more granular control over message flags (like setting deleted flags). Calling Expunge removes messages permanently. If some messages aren't deleted, ensure proper flag handling before calling Expunge to guarantee deletion.
           | Posted: 28 February 2025 at 4:29am | IP Logged |   |  
           | 
 |  
 
 
 
 
 
 
 https://alightmotionapks.net/
 | 
       
        | Back to Top |     | 
       
       
        |  |