' ****************************************************************************
' Description:  Tutorial 10, Working with Received Messages.  This script shows 
'               find a message in an Outpost folder, and then then forwards it.
'               to another user.
'               NOTE:  See the FindMessage and NextMessage statements for more
'               details.
' Author:       Jim  KN6PE
' Revision:     09/18/08: Original
' ****************************************************************************

SCRIPT
VAR MsgID AS NUMBER

BEGIN

' Look for a message in the In Tray from K6KP; forward it to KN6PE

FindMessage(1, 2, "K6KP")

' The following NextMessage statement retrieves each message that matches these
' conditions.  As long as MsgID is not "0", then a message has been retrieved.
' The fields -- BBS, FROM, TO, SUBJECT, MESSAGE, and MTYPE -- are populated 
' with the message contents for the message just retrieved.

MsgID = NextMessage(0)

While MsgID > 0            ' as long as MsgID is > 0, we have a match

' BEGIN CREATING THE MESSAGE TO FORWARD
' With everything the same, just change the TO field to KN6PE...
    TO = "KN6PE"	     	

' ... and the MESSAGE Body.  Because the MESSAGE parameter contains the original
' message, we want to insert some text in front of it so that KN6PE knows it was
' OSL-forwarded.

    MESSAGE = "OSL-forwarded from K6KP" & CRLF & MESSAGE

' And, create the message
  CreateMessage

  SendReceive             ' Finally, send it, and move it to the Archive
  MoveMessage(MsgID, 4)   ' Move the original message to the Archive
  MsgID = NextMessage(0)  ' get the next message if it exists, and do it again

EndWhile

END