RetrieveSingleMessageHeaders Method

Retrieves a message's headers from currently selected IMAP4 mailbox.

Also, this method is capable of retrieving portion of the message body. This allows client to preview message body.

To retrieve the whole message, use RetrieveSingleMessage method.

Note: It's more effective to get headers for multiple messages at once using RetrieveEnvelopes or RetrieveEnvelopesEx methods. These methods return collections of Envelope objects which are usually more suitable for message preview purposes (such as displaying message lists).

objMessage = ObjectName.RetrieveSingleMessageHeaders(Index, AsUID, [BodyPreviewSize])  
Index As Long Message number or UID of the message to retrieve  
AsUID As Boolean If True, Index parameter must be specified as UIDs (unique-IDs). Otherwise, Index must be a message number  
BodyPreviewSize As Long (optional) Specifies the number of bytes of the message body to be returned in addition to message headers. If -1 or -2, the entire message is downloaded (-2 also sets \Seen flag). Default is 0  
Return value As MailBee.Message On success, the method returns Message object which represents the message. On failure, return value is Nothing  

Usage example:

' This sample retrieves headers and first 500 bytes of the body of
' the last message in Inbox, and displays the retrieved portion of the body
Dim Mailer, Message
'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.LicenseKey = "put your license key here"
If Mailer.Connect("", 143, "MyName", "MyPassword") Then
  If Mailer.SelectMailbox("Inbox") Then
    Set Message = Mailer.RetrieveSingleMessageHeaders(Mailer.MessageCount, False, 500)
    If Not Message Is Nothing Then
      MsgBox Message.BodyText
    End If
  End If
End If

See Also:

Envelope Object
Message Object

RetrieveEnvelopes Method
RetrieveEnvelopesEx Method
RetrieveSingleMessage Method

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