ParseMessage Method  
 

Parse the specified string, adding the contents to the current message.

Syntax

object.ParseMessage( MessageText )

Parameters

MessageText
A string that contains the message text to be parsed.

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 ParseMessage method parses a string which contains message data, adding it to the current message. This method is useful when the application needs to parse an arbitrary block of text and add it to the current message. If the string contains header fields, the values will be added to the message header. Once the end of the header block is detected, all subsequent text is added to the body of the message.

Note that unlike the ImportMessage method, the ParseMessage method does not clear the contents of the current message and may be called multiple times. Use the ClearMessage method to clear the current message before calling ParseMessage if necessary.

Example

The following example demonstrates the use of ParseMessage to parse multiple blocks of data from a file. This example effectively does the same thing as calling the ImportMessage method:

MailMessage1.ClearMessage
    
hFile = FreeFile()
Open strFileName For Input As hFile
nFileLength = LOF(hFile)
    
Do While nFileLength > 0
    '
    ' Read the contents of the file in 1K blocks; note that
    ' this is intentionally inefficient to demonstrate
    ' multiple calls to the ParseMessage method.
    '
    cbBuffer = nFileLength: If cbBuffer > 1024 Then cbBuffer = 1024
    nFileLength = nFileLength - cbBuffer
    strBuffer = Input(cbBuffer, hFile)
    '
    ' Parse the string, adding to the current message
    '
    nError = MailMessage1.ParseMessage(strBuffer)
    If nError > 0 Then
        MsgBox MailMessage1.LastErrorString, vbExclamation
        Exit Do
    End If
Loop
    
Close hFile

See Also

ClearMessage Method, ImportMessage Method