Retrieve the specified message from the mail server.
Syntax
object.GetMessage( [Number] )
The GetMessage method syntax has the following parts:
| Part |
Description |
| object
|
An object expression that
evaluates to an InternetMail object. |
| number
|
A long integer which specifies the
message to retrieve. |
Remarks
The GetMessage method retrieves the specified message
from the mail server. This method will cause the current message to
be replaced with the new message, and the MessageIndex
property will be updated with the new message number. If the
optional message Number argument is not specified, then the
value of the MessageIndex property is used instead.
Note that unlike setting the MessageIndex property, which
only causes the headers for the specified message to be retrieved,
the GetMessage method downloads the complete message. The
OnProgress event will fire periodically as the message is
retrieved, allowing an application to update its user interface if
desired.
This method will return a value of zero if the action was
successful. Otherwise, a non-zero error code is returned which
indicates the cause of the failure.
Example
The following example connects to a mail server and retrieves
the first message:
Dim nError As Long
nError = InternetMail1.Connect(strServerName, , strUserName, strPassword)
If nError <> 0 Then
MsgBox "Unable to connect to " & strServerName & vbCrLf & _
InternetMail1.LastErrorString, vbExclamation
Exit Sub
End If
If InternetMail1.LastMessage = 0 Then
MsgBox "The mailbox is currently empty", vbInformation
InternetMail1.Disconnect
Exit Sub
End If
nError = InternetMail1.GetMessage(1)
If nError <> 0 Then
MsgBox "Unable to retrieve the message" & vbCrLf & _
InternetMail1.LastErrorString, vbExclamation
Next
InternetMail1.Disconnect
See Also
MessageIndex
Property, GetHeader Method,
OnProgress Event
|