| Author |  | 
      
        | Guests Guest Group
 
  
 
 Joined: 10 November 2003
 Online Status: Online
 Posts: 262
 | 
          I am retreiving all the messages and by using a for loop i am cycling through all the emails. I am trying to have it delete a message when the subject line contains certain text. So in ASP i wrote this
           | Posted: 09 January 2004 at 12:26pm | IP Logged |   |  
           | 
 |  Set objMsg = objPOP3.RetrieveMessages
 For Each Msg In objMsg
 if instr(Msg.Subject,"delete me")>0 then Msg.DeleteMessage
 Next
 
 
 but i get an error that the object doesnt support this.
 What am i doing wrong?
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Alex AfterLogic Support
 
  
  
 Joined: 19 November 2003
 Online Status: Offline
 Posts: 2207
 | 
          DeleteMessage is a method of POP3 object. The code should be as follows:
           | Posted: 09 January 2004 at 1:30pm | IP Logged |   |  
           | 
 |  
 Set objMsgs = objPOP3.RetrieveMessages
 For I = 1 To objMsgs.Count
 Set objMsg = objMsgs(I)
 If InStr(objMsg.Subject, "delete me") > 0 Then
 objPOP3.DeleteMessage I
 End If
 Next
 
 BTW, if you do not need message body (i.e. if all procesing is about analyzing headers such as Subject), you may use RetrieveHeaders instead. This will work much faster.
 
 Also, it's recommended to check objMsgs for Nothing before use. POP3 object returns Nothing if connection is lost during messages download.
 
 Set objMsgs = objPOP3.RetrieveMessages
 If objMsgs Is Nothing Then
 ' Error!
 Else
 ' All's fine
 End If
 
 
 | 
       
        | Back to Top |     | 
       
       
        |  |