Creating the Default Message

For the creation of a classified ad form, Read.asp is opened as the default file. In this script, the first step is the creation of a standard message. This happens in the following line of code, by the addition of a message to the current profile's (the session's) Outbox:

Set oNewMessage = objAMSession.Outbox.Messages.Add
 

In this call, objAMSession is the handle to the current session, and oNewMessage is the handle to the new message object. This new message contains the default fields of a standard message. The message handle is used later in this script when the message is sent with the command oNewMessage.Send. The Send command can include various flags, such as for requesting a delivery receipt or saving a copy in the Sent Items folder.

Because this call requests memory for a message object, it can fail if the computer is currently low on memory. For this reason, it may be good to check the return value from this call. In VBScript, if the object creation fails in a given call, the return value is set to Nothing. (In this code, rather than checking if the new message is set to Nothing, the creation of child objects is checked a few lines of code later.)