Retrieve the specified message from the mail server.
Syntax
object.GetMessage( [MessageNumber] )
Parameters
- MessageNumber
- An optional integer value that specifies the message number.
Return Value
A value of zero is returned if the method succeeds.
Otherwise, a non-zero error code is returned which indicates the
cause of the failure.
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
MessageNumber 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.
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
|