InternetMail.GetUIDL

Syntax:

GetUIDL(<ArrayOfIdentifiers>, <FilterParameters>)

Parameters:

<ArrayOfIdentifiers> (optional)

Type: Array.
To receive all UIDs of messages in the mail box you need to transfer an empty array. If you want to receive only new messages' UIDs, you need to transfer the array, filled by UIDs received earlier (the UID property).

<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.
  • 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:

It returns an array, containing identifiers of all or new messages in mail box on server.
Caution! Headers are filtered only during operations via the IMAP protocol. If the POP3 protocol is used, letters are not filtered – the method will return a full array of messages even if FilterParameters are set.

Availability:

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

Note:

For the IMAP protocol identifiers are selected from the IMAP mail box(CurrentMailbox).

Example:

Profile = New InternetMailProfile;
FillInProfile(Profile);

Mail = New InternetMail;
Mail.Logon(Profile);

IDs = New Array;
// Restore previously saved IDs 
ResValue = RestoreValue("IDs");
If 
ResValue <> Undefined Then
    IDs = ResValue
EndIf;

// Get IDs of new messages
NewMess = Mail.GetId(IDs);

If 
NewMess.Count() > Then

    // Get only new messages
    Array = Mail.Get(False, NewMess);

Else

    Message("No new messages");
    Mail.Logoff();
    Return
;

EndIf
;       

For 
Each Letter In Array Do

    // Save ID of the message we got, 
  // in order to use it later
  IDs.Add(Letter.UID[0]);
    Message(Letter.UID[0]);

    // ...

EndDo
;

SaveValue("IDs", IDs);

Mail.Logoff();

See also:

InternetMailMessage, property UID

    

1C:Enterprise Developer's Community