Store the specified message in a file.
Syntax
object.StoreMessage( MessageNumber,
FileName )
Parameters
- MessageNumber
- An integer value which specifies the message to store.
- FileName
- A string value that specifies the name of the file to store the
message in.
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 StoreMessage method retrieves the specified message
from the mail server and stores it in a file. The number
argument specifies the message to retrieve and the filename
argument specifies the name of the file that the message will be
stored in.
For applications which need to store messages on the local system,
the StoreMessage method is somewhat more efficient than using
the GetMessage and ExportMessage methods to load and
store the message. StoreMessage does not attempt to analyze
the message or change the current message contents.
Example
The following example connects to a mail server and retrieves each
of the mail messages, storing them in a file on the local system:
Dim strFileName As String
Dim nMessage As Long, 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
For nMessage = 1 To InternetMail1.LastMessage
strFileName = "c:\temp\msg" & Format(nMessage, "00000") & ".txt"
nError = InternetMail1.StoreMessage(nMessage, strFileName)
If nError > 0 Then
MsgBox "Unable to store message " & nMessage & vbCrLf & _
InternetMail1.LastErrorString, vbExclamation
Exit For
End If
Next
If nError = 0 Then
MsgBox "Stored " & InternetMail1.LastMessage & " messages", vbInformation
End If
InternetMail1.Disconnect
See Also
GetMessage Method,
ExportMessage Method
|