UID Property


Contains the unique-id (UID) of the message.

UID is a 32-bit number which uniquely identifies the message in IMAP4 mailbox. This number is guaranteed to be always larger for each new message in the mailbox than any UIDs of the messages existed in the mailbox before.

UIDs are useful for message management and search (such as looking for or retrieving new messages). Most methods of IMAP4 object allow UIDs as alternative form of message indices.

Note: Dont't confuse UID with MessageID (which is a string taken from "Message-ID" message header).


Value Type: Long
Parameters: None 
Remarks: This property is read-only

Usage example:

' This sample displays UID of the last message in Inbox
Dim Mailer, Envelopes, Envelope
'Using visual basic to create object
Set Mailer = CreateObject("MailBee.IMAP4")
'Using ASP to create object
'Set Mailer = Server.CreateObject("MailBee.IMAP4")
'In ASP use Response.Write instead of MsgBox
Mailer.EnableLogging = True
Mailer.LogFilePath = "C:\Temp\imap4_log.txt"
Mailer.ClearLog
Mailer.LicenseKey = "put your license key here"
If Mailer.Connect("mailserver.com", 143, "MyName", "MyPassword") Then
  If Mailer.SelectMailbox("Inbox") Then
    Set Envelopes = Mailer.RetrieveEnvelopes(Mailer.MessageCount, Mailer.MessageCount, False)
    If Not Envelopes Is Nothing Then
      For Each Envelope In Envelopes
        MsgBox Envelope.UID
      Next
    End If
  End If
  Mailer.Disconnect
End If

See Also:

IMAP4.Search Method


Copyright © 2002-2022, AfterLogic Corporation. All rights reserved.