ParseMessage Method

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

Syntax

object.ParseMessage( Msgtext )

The ParseMessage method syntax has the following parts:

Part Description
object An object expression that evaluates to an InternetMail object.
msgtext A string which specifies the message text to be parsed.

Return Type

Integer

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.

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 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:

    InternetMail1.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 = InternetMail1.ParseMessage(strBuffer)
        If nError <> 0 Then
            MsgBox InternetMail1.LastErrorString, vbExclamation
            Exit Do
        End If
    Loop
    
    Close hFile

See Also

ClearMessage Method, ImportMessage Method


Copyright © 2008 Catalyst Development Corporation. All rights reserved.