IMAP4Flags Property

Specifies the behaviour of ANPOP for retrieving/deleting email from IMAP4 server.


Data Type: Long

Value Meaning
1 If this flag is set, Delete method only sets "Deleted" flag to email, but doesn't pure it from the IMAP4 server.
2 If this flag is set, Retrieve method will set "Seen" flag to the email automatically.
4 If this flag is set, GetTotalOfMails will not count the mail with "Seen" flag.
8 If this flag is set, GetTotalOfMails will not count the mail with "Deleted" flag.

Remarks

The value of the property can also include any combination of the above flags.

Usage Example

[Visual Baisc]

Sub Retrieve( pop3Server As String, pop3User As String, pop3Password As String )

  Dim oPop3 As ANPOPLib.POPMAIN
  Dim oMsg As ANPOPLib.POPMSG
  Dim i, nRet, nSize, nCount As Integer
  Dim emailContent, messageId, err As String
  
  Const LOGOUT_WITHOUT_EXPUNGE = 1
  Const AUTO_MARK_AS_READ = 2
  Const IGNORE_READ_MAIL = 4
  Const IGNORE_DELETED_MAIL = 8
  
  Set oPop3 = new ANPOPLib.POPMAIN 'Create object instance
  Set oMsg  = new ANPOPLib.POPMSG
  
  oPop3.IMAP4Connection = 1
  oPop3.ServerPort = 143

  oPop3.IMAP4Flags = ( LOGOUT_WITHOUT_EXPUNGE OR AUTO_MARK_AS_READ )
  oPop3.IMAP4Flags = ( oPop3.IMAP4Flags OR IGNORE_DELETED_MAIL )

  err = ""
  nRet = oPop3.Connect( pop3Server, pop3User, pop3Password ) 'Connect pop3 server
  If nRet <> 0 Then
    err = "error with connecting server"
    goto ErrorHandler
  End If
  
  nCount = oPop3.GetTotalOfMails() 'Get total count of emails
  If nCount = -1 Then
    err = "error with GetTotalOfMails"
    goto ErrorHandler  
  ElseIf nCount = 0 Then
    err = "no email"
    goto ErrorHandler
  End If
  
  For i = 1 To nCount    
    emailContent = oPop3.Retrieve(i) 'Retrieve email and mark the email as seen
    If emailContent = vbnullstring Then
      err = "error with Retrieve" 
      goto ErrorHandler
    End If
    
    oMsg.RawContent = emailContent
    nRet = oMsg.ExportFile( "c:\pop3Test_" & i & ".eml") 'Save email
    If nRet <> 0 Then
      err = "error with ExportFile"
      goto ErrorHandler
    End If
    
    'Mark the email as deleted.
    If oPop3.Delete(i) <> 0 Then 
      err = "error with Delete"
      goto ErrorHandler
    End If
  Next
  
ErrorHandler:
  Call oPop3.Close() 'Close connection
  Set oPop3 = Nothing
  Set oMsg = Nothing
  
End Sub

See Also

Connect Method


2001-2007 © Copyright AdminSystem Software Limited. All rights reserved.