IMAP4Folder Property

Because IMAP4 protocol supports retrieving emaile from specified mailbox, so this property specifies the mailbox(folder) name, the default value is "INBOX".


Data Type: String

Remarks

If the folder name is changed after anpop connected the server, GetTotalOfMails method should be used to refresh the total number of the mails in the new folder.

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
  
  Set oPop3 = new ANPOPLib.POPMAIN 'Create object instance
  Set oMsg  = new ANPOPLib.POPMSG
  
  oPop3.IMAP4Connection = 1
  oPop3.ServerPort = 143
  oPop3.IMAP4Folder = "Deleted Items" ''retrieve emails from folder: Deleted Items.
  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
    nSize = oPop3.GetMsgSize(i) 'Get email size
    If nSize = -1 Then
      err = "error with GetMsgSize"   
	  goto ErrorHandler
    End If
    
    messageId = oPop3.GetMsgID(i) 'Get message-id
    If messageId = vbnullstring Then
	  err = "error with GetMsgId"  
	  goto ErrorHandler
    End If
    
    emailContent = oPop3.Retrieve(i) 'Retrieve email
    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
    
    If oPop3.Delete(i) <> 0 Then 'Delete email from server
      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.