DataFlex
DataFlex
Fetch the Flags Set on an IMAP Message
See more IMAP Examples
Demonstrates the Chilkat Imap.FetchFlags method, which returns the flags currently set on a single message as a space-separated string. The first argument is the message ID and the second (bUid) selects UID vs sequence number. This example fetches and prints the flags for one message identified by UID.
Background: The returned string is the server's current flag list for the message, such as
\Seen \Flagged. This is a quick way to check a single message's state — for example, to decide whether it still needs processing — without downloading the message itself. To read the same information from a message you already have as an Email object, use GetMailFlag instead.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoImap
Variant vMsgSet
Handle hoMsgSet
UInteger iUid
String sFlags
String sTemp1
Integer iTemp1
Boolean bTemp1
Move False To iSuccess
// Demonstrates the Imap.FetchFlags method, which returns the flags currently set on a single
// message as a space-separated string. The 1st argument is the message ID and the 2nd (bUid)
// selects UID vs sequence number.
Get Create (RefClass(cComChilkatImap)) To hoImap
If (Not(IsComObjectCreated(hoImap))) Begin
Send CreateComObject of hoImap
End
Set ComSsl Of hoImap To True
Set ComPort Of hoImap To 993
Get ComConnect Of hoImap "imap.example.com" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoImap To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComLogin Of hoImap "user@example.com" "myPassword" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoImap To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComSelectMailbox Of hoImap "Inbox" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoImap To sTemp1
Showln sTemp1
Procedure_Return
End
Get Create (RefClass(cComChilkatMessageSet)) To hoMsgSet
If (Not(IsComObjectCreated(hoMsgSet))) Begin
Send CreateComObject of hoMsgSet
End
Get pvComObject of hoMsgSet to vMsgSet
Get ComQueryMbx Of hoImap "ALL" True vMsgSet To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoImap To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComCount Of hoMsgSet To iTemp1
If (iTemp1 > 0) Begin
Get ComGetId Of hoMsgSet 0 To iUid
// FetchFlags returns a string, so assign it to a string variable and check for success.
Get ComFetchFlags Of hoImap iUid True To sFlags
Get ComLastMethodSuccess Of hoImap To bTemp1
If (bTemp1 = False) Begin
Get ComLastErrorText Of hoImap To sTemp1
Showln sTemp1
Procedure_Return
End
Showln "UID " iUid " flags: " sFlags
End
Get ComDisconnect Of hoImap To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoImap To sTemp1
Showln sTemp1
Procedure_Return
End
End_Procedure