send_message NSSOAP Methods

The send_message method submits a message to a NET SatisFAXtion server for delivery as fax or e-mail.  The message must contain one or more destination addresses provided in an array of RECIPIENT objects, and some form of content provided in an array of CONTENT objects.  The fax server assigns ownership of the submitted message to the user specified with the user_name parameter. 

The send_message method submits a message for delivery, but returns control to the calling application before the message has been delivered. For successful submissions, the SEND_MESSAGE_RESULT object returned from send_message contains the handle for the new message.  This handle can be used in subsequent methods, including abort_message, delete_message, and get_message.

The typical progression for a submitted message is to go from the scheduled queue where it remains until all attachments are converted, to the sending queue where it is delivered by fax hardware, to the sent queue where the application calls get_message or get_message_q to retrieve the result code, and then calls delete_message to delete the completed message.

SEND_MESSAGE_RESULT send_message(
  string       user_name, // Fax server user name
  string       user_password, // Fax server user password
  MESSAGE_INFO message_info, // Message details
  RECIPIENT[]  recipients, // Array of recipients 
  CONTENT[]    content // Array of message content
)


Parameters:
user_name A NET SatisFAXtion user name.

user_password The password for the user.

message_info A MESSAGE_INFO object with fields filled in to enable various features. This parameter is optional and can be null.

recipients An array of RECIPIENT objects.  At least one RECIPIENT object must be provided in the array.

content An array of CONTENT objects.  At least one CONTENT object must be provided in the array.

Return Value:
A SEND_MESSAGE_RESULT object containing a result code and string, and a new message handle if the function was successful.

Example:
public string send_fax()
  {
  try
    {
    MESSAGE_INFO mi = new MESSAGE_INFO();
    mi.sender_name  = "My Name";

    RECIPIENT r = new RECIPIENT();
    r.address = "5551231234";
    r.name    = "Fred";

      // Some text to merge in the cover template

    CONTENT c1 = new CONTENT();
    c1.part = CONTENT_PART.CoverMessage;
    FileStream fs = new FileStream(@"c:\Cover.txt",FileMode.Open);
    c1.content_data = new byte[fs.Length];
    fs.Read(c1.content_data,0,c1.content_data.Length);
    fs.Close();

      // A PDF attachment (important to provide a name)

    CONTENT c2 = new CONTENT();
    c2.part = CONTENT_PART.Attachment;
    c2.name = "FaxBody.pdf";
    fs = new FileStream(@"c:\FaxBody.pdf",FileMode.Open);
    c2.content_data = new byte[fs.Length];
    fs.Read(c2.content_data,0,c2.content_data.Length);
    fs.Close();

    NSSOAP ns = new NSSOAP();

    SEND_MESSAGE_RESULT smr =
      ns.send_message("supervisor",
                      "",
                      mi,
                      new RECIPIENT[]{r},
                      new CONTENT[]{c1,c2});
    
    if (smr.status_num == STATUS_NUM.NoError)
      {
      return(smr.message_handle);
      }

      // Error in smr.status_string
    }  
  
  catch (Exception e)
    {
      // error in e.Message
    }
  
  return(null);
  }

See Also:
get_message_q, get_message, abort_message, delete_message, MESSAGE_INFO, RECIPIENT, CONTENT