DataFlex
DataFlex
List Email UIDs
List the UIDs of each email in a mailbox.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoImap
Boolean iFetchUids
Variant vMessageSet
Handle hoMessageSet
Integer i
Integer n
String sTemp1
Integer iTemp1
Move False To iSuccess
Get Create (RefClass(cComChilkatImap)) To hoImap
If (Not(IsComObjectCreated(hoImap))) Begin
Send CreateComObject of hoImap
End
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
// Connect to an IMAP server.
// Use TLS
Set ComSsl Of hoImap To True
Set ComPort Of hoImap To 993
Get ComConnect Of hoImap "MY-IMAP-DOMAIN" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoImap To sTemp1
Showln sTemp1
Procedure_Return
End
// Login
Get ComLogin Of hoImap "MY-IMAP-LOGIN" "MY-IMAP-PASSWORD" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoImap To sTemp1
Showln sTemp1
Procedure_Return
End
// Select an IMAP mailbox
Get ComSelectMailbox Of hoImap "Inbox" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoImap To sTemp1
Showln sTemp1
Procedure_Return
End
// Get the message IDs of all the emails in the mailbox
// We can choose to fetch UIDs or sequence numbers.
Move True To iFetchUids
Get Create (RefClass(cComChilkatMessageSet)) To hoMessageSet
If (Not(IsComObjectCreated(hoMessageSet))) Begin
Send CreateComObject of hoMessageSet
End
Get pvComObject of hoMessageSet to vMessageSet
Get ComQueryMbx Of hoImap "ALL" iFetchUids vMessageSet To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoImap To sTemp1
Showln sTemp1
Procedure_Return
End
Move 0 To i
Get ComCount Of hoMessageSet To n
While (i < n)
Get ComGetId Of hoMessageSet i To iTemp1
Showln iTemp1
Move (i + 1) To i
Loop
// Disconnect from the IMAP server.
Get ComDisconnect Of hoImap To iSuccess
End_Procedure