|
Summary
Sets a flag that specifies the specific section of the message to be retrieved.
Description
This property can be used to specify the particular sections of a message to be fetched by the application.
This property is set in the OnBodyAttributes event that occurs in response to calling the Fetch or UidFetch method with the DataItems parameter containing IMAP_BODY or IMAP_BODY_PEEK. The BodyFlags
property must contain one of the following values.
| IMAP_ENTIRE_MESSAGE |
Gets the entire message |
| IMAP_HEADER |
Gets the initial header |
| IMAP_HEADER_FIELDS |
Gets only specific header fields |
| IMAP_HEADER_FIELDS_NOT |
Gets all the header fields except the specified ones |
| IMAP_TEXT |
Gets the text portion of the message |
| IMAP_MIME_PART_HEADER |
Gets the header of a MIME section |
| IMAP_MIME_PART_BODY |
Gets the body of a MIME section |
To fetch the entire message including the header the BodyFlags property must be set to IMAP_ENTIRE_MESSAGE. To fetch the entire text section of the message the BodyFlags property
should be set to IMAP_TEXT.
To retrieve the entire initial header the BodyFlags property should be set to IMAP_HEADER. To retrieve only the specified fields from the initial header the BodyFlags property
should be set to IMAP_HEADER_FIELDS. In this case the BodyHeaderFields property must contain the name of the header fields that needs to be fetched. If you do not wish to fetch certain parts of the
header then this property needs to be set to IMAP_HEADER_FIELDS_NOT; in this case the specified fields will not be fetched. The fields must be space separated, for example if the application wants to
fetch only the "from" and the "to" fields then the BodyHeaderFields property should contain "from to".
Note that IMAP_HEADER, IMAP_HEADER_FIELDS_NOT, IMAP_HEADER_FIELDS should be used only to fetch the fields of the initial header or the encapsulated header of a message of type message/rfc822. To get
any portion of a multipart MIME message the application must use IMAP_MIME_PART_HEADER or IMAP_MIME_PART_BODY.
To get the header or the body of a specified section of a multipart message this property should be set to IMAP_MIME_PART_HEADER or IMAP_MIME_PART_BODY respectively. The BodyPart property
should be set to the section number of the message to retrieve.
If the BodyFlags property has the value IMAP_ENTIRE_MESSAGE, IMAP_HEADER, IMAP_HEADER_FIELDS, IMAP_HEADER_FIELDS_NOT, IMAP_TEXT or IMAP_MIME_BODY_PART then the Distinct IMAP ActiveX control will fire
the OnData event to deliver the data to the application. In the case of IMAP_MIME_PART_HEADER the Distinct IMAP ActiveX control will parse the header and will deliver the data in the OnMimeHeader
event.
The BodyPart property specifies the message section number that needs to be fetched. The application must specify a part only if it is trying to fetch a part of a multipart message or a message of
type message/rfc822. In all the other cases the BodyPart should be set to an empty string. If the BodyFlags property is set to IMAP_HEADER, IMAP_HEADER_FIELDS, IMAP_HEADER_FIELDS_NOT or IMAP_TEXT the
BodyPart property is usually not used unless the application is trying to fetch the encapsulated header of message/rfc822. The BodyPart property is important when the BodyFlags property is either
IMAP_MIME_PART_HEADER or IMAP_MIME_PART_BODY.
When fetching message data the application may fetch a substring of the designated string, in that case the BodyStartOctet and BodyNumOctets properties are used to specify the octet position of the
first and the number of octets to retrieve.
If used this property should be set at run time in the OnBodyAttributes event. There is no default value for this property.
Example
Private Sub Imap_OnBodyAttributes()
If (not AttrDone) Then
Imap.BodyFlags = IMAP_MIME_PART_BODY
Imap.BodyHeaderFields = ""
'Get section number 1
Imap.BodyPart = "1"
'Get the entire section
Imap.BodyStartOctet = -1
Imap.BodyNumOctets = -1
AttrDone = True
Else
Imap.BodyFlags= 0
End If
End Sub
See Also
BodyStartOctet, BodyNumOctet, BodyPart and BodyHeaderFields properties;
OnData, OnMimeHeader and OnBodyAttributes events
|