(PureBasic) POP3 Fetch a Single Email by UIDL
Demonstrates how to fetch a single email by UIDL.
IncludeFile "CkMailMan.pb"
IncludeFile "CkEmail.pb"
IncludeFile "CkStringArray.pb"
Procedure ChilkatExample()
; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
mailman.i = CkMailMan::ckCreate()
If mailman.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkMailMan::setCkMailHost(mailman, "pop.example.com")
CkMailMan::setCkPopUsername(mailman, "myLogin")
CkMailMan::setCkPopPassword(mailman, "myPassword")
CkMailMan::setCkMailPort(mailman, 995)
CkMailMan::setCkPopSsl(mailman, 1)
sa.i = CkMailMan::ckGetUidls(mailman)
If CkMailMan::ckLastMethodSuccess(mailman) = 0
Debug CkMailMan::ckLastErrorText(mailman)
CkMailMan::ckDispose(mailman)
ProcedureReturn
EndIf
; Download each email by UIDL.
uidl.s
i.i = 0
numUidls.i = CkStringArray::ckCount(sa)
While i < numUidls
uidl = CkStringArray::ckGetString(sa,i)
Debug uidl
email.i = CkMailMan::ckFetchEmail(mailman,uidl)
If CkMailMan::ckLastMethodSuccess(mailman) = 0
Debug CkMailMan::ckLastErrorText(mailman)
CkMailMan::ckDispose(mailman)
ProcedureReturn
EndIf
Debug CkEmail::ckSubject(email)
Debug ""
CkEmail::ckDispose(email)
i = i + 1
Wend
CkStringArray::ckDispose(sa)
CkMailMan::ckDispose(mailman)
ProcedureReturn
EndProcedure
|