AxEmail.ImapFetchData
Introduction
Skip to properties and methods
The ImapFetchData object represents some data item that was fetched from the IMAP server using FetchFirst/FetchNext.
Fetch data may be nested. This means that a fetch data object may be a collection of other fetch data objects which may in turn be a collection of other fetch data objects, etc.
This is an example on using the FetchData object:
Set objImap = CreateObject("AxEmail.Imap")
Set objConstants = CreateObject("AxEmail.Constants")
' ...
Set objFetchData = objImap.FetchFirst(objConstants.IMAP_SK_ALL, objConstants.IMAP_FM_ALL)
While objImap.LastError = 0
' Get the top-level envelope element from the fetch data
Set objEnvelope = objFetchData.GetSubDataByName("ENVELOPE")
Set objFrom = objEnvelope.GetSubData(2).GetSubData(0)
Set objTo = objEnvelope.GetSubData(4).GetSubData(0)
WScript.Echo "Email UID: " & objFetchData.GetSubDataByName("UID").ValueAsInt
WScript.Echo " Date: " & objEnvelope.GetSubData(0).Value
WScript.Echo " From: " & objFrom.GetSubData(2).Value & "@" & objFrom.GetSubData(3).Value
WScript.Echo " To: " & objTo.GetSubData(2).Value & "@" & objTo.GetSubData(3).Value
WScript.Echo " Subject: " & objEnvelope.GetSubData(1).Value
WScript.Echo
Set objFetchData = objImap.FetchNext
WEnd
' ...
Properties and Methods
Property | Type | Read/Write | Description |
LastError | Number | Read | Result of the last called method |
Value | String | Read | Value of this data item as string |
ValueAsInt | Integer | Read | The value of this data item as integer |
Type | Integer | Read | The type of this value as determined by the parser |
Text | String | Read | The raw protocol text representation of this fetch data item and all its sub-items |
IsTopLevel | Boolean | Read | Whether this fetch data item is a top level item or a sub-item |
Sequence | Number | Read | Sequence number for untagged top-level fetch data |
Method | Description |
GetErrorDescription | Get the description of the given error |
GetSubDataCount | Get the number of sub-data items that are contained in this data item |
GetSubData | Get a sub-data item by index |
GetSubDataByName | Get a sub-data item by name; only for top-level fetch data items |
ContainsValue | Check if this data item or one of its sub-data items contains the given value |
ContainsIntValue | Check if this data item or one of its sub-data items contains the given integer value |
LastError property
Completion code of the last called function. To find the error description of a given error code, go to the online error codes codes page.
Value property
This is the actual value of the current data item represented as a string.
ValueAsInt property
This is the actual value of the current data item represented as an integer.
Type property
The type of this value as determined by the parser. Can be one of these constants.
Text property
The raw protocol text representation of this fetch data item and all its sub-items. This is mainly intended for troubleshooting purposes.
IsTopLevel property
Contains whether this fetch data item is a top level item or a sub-item.
An ImapFetchData object that was returned directly from FetchFirst/FetchNext will always have this property set to True. Sub items will always have this property set to False.
Sequence property
This is the sequence number of the e-mail this fetch data item relates to. This is only set if this object represents top-level fetch data item.
GetErrorDescription method
GetErrorDescription provides the error description of a given error code.
Parameters:
- The error code
Return value:
The error string.
GetSubDataCount method
Parameters
- None
Return Value
The number of sub-data items
GetSubData method
Parameters
- Index
Return Value
GetSubDataByName method
Parameters
- Fetch Data Name
Return Value
ContainsValue method
Parameters
- Value as string
Return Value
True if the value is found else False
ContainsIntValue method
Parameters
- Value as integer
Return Value
True if the value is found else False