InternetMail.GetHeaders

Syntax:

GetHeaders(<FilterParameters>)

Parameters:

<FilterParameters> (optional)

Type: Structure.
Names of message properties by which the filter is performed, are used as structure keys.
Values can be expressions of the following types: String, Date, Number, Boolean.
Value type is defined by a key. For example, if you want to select messages till the specified date, then you should use expressions of Date type as value. If a string is used as value, then register does not matter.
If several keys are specifies, then they are applied sequentially by logical AND.
If the key value transferred in the structure is not supported, the value will be ignored, no error occurs in this case.
  • Answered - Boolean. Select messages, which have the Answered checkbox set;
  • Recent - Boolean. Select messages, which arrived during the current IMAP session. If this parameter is set, the IMAP2 parameter Recent is generated;
  • Bcc - String. Select messages, which have "string" in the Bcc field;
  • Cc - String. Select messages, which have "string" in the Cc field;
  • To - String. Select messages, which have "string" in the To field;
  • PostDating - Date. Select messages, where the Date field is set to "Date";
  • From - String. Select all messages, where "string" occures in the From field;
  • BeforeDateOfPosting - Date. Select messages, where value of Date field: before “Date”;
  • AfterDateOfPosting - Date. Select messages, where value of Date field: after the value of “Date”;
  • Subject - String. Select messages, in headers of which the specified string occurs;
  • Text - String. Select messages, in any text fields of which the specified string occurs;
  • Body - String. Select messages, in whose body the string "string" occurs;
  • Deleted - Boolean. Select messages, which must be or must not be deleted;
  • Flagged - Boolean. Select messages, which are marked or not marked with the flag;
  • Seen - Boolean. Select messages, which were read or unread;
  • New - Boolean. Select new or old messages.
Example:
IMAPFilterParameters = New Structure;
IMAPFilterParameters.Insert("New", True);
IMAPFilterParameters.Insert("Message", "hello");
Mail.GetHeaders(IMAPFilterParameters);



String values of filter criterios are send using the US-ASCII encoding, if they contain only ANSI characters, and in UTF-8 encoding otherwise. Some IMAP servers do not support UTF-8 encoding, so the server can display the corresponding error.

Returned value:

Type: Array.

Description:

Generates an array that contains objects of the InternetMailMessage type. Each object contains only a message header. You can use it to select headers of all messages on the server. Each object contains only the following fields:
  • Header
  • Size
  • Message-ID
  • Subject
  • Sender
  • ReplyTo
  • To
  • BCC
  • PostDating.
Headers of all messages on the server are selected.

Availability:

Thin client, server, thick client, external connection, Mobile application (client), Mobile application (server).

Note:

This array is processed by the user and is passed to Get method as a parameter. The Get method gets specified messages completely, and returns them in a array.
For the IMAP protocol headers are selected from the IMAP mail box (CurrentMailbox).
Important! The headers are filtered only for IMAP protocol. Filter is not used when operating using the POP3 protocol - method returns the full array of messages, even if FilterParameters are set.

Example:

Profile = New InternetMailProfile;
// ...
// filling the profile
// ...

Mail = New InternetMail;
Mail.Logon(Profile);
Headings  = Mail.GetHeaders();
If 
Headings.Count() = 0 Then
    DoMessageBox("There are no messages on the server!", , "No messages");
EndIf
;

// select message headings, which we need to receive fully 
// from the array

Letters = Mail.Get(True, Headings);

// Messages and Headings contains identical
// set of full messages

Mail.Logoff();

See also:

InternetMail, method Get

    

1C:Enterprise Developer's Community