SEND_MESSAGE

CAS Tags
The SEND_MESSAGE function 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 with RECEIVER_ADDRESS sections, and some form of content provided with one or more CONTENT_PART sections.  The fax server assigns ownership of the submitted message to the user specified with the REGISTERED_NAME tag. 

The SEND_MESSAGE function submits a message for delivery, but returns control to the calling application before the message has been delivered. For successful submissions, the return taglist from SEND_MESSAGE contains the MESSAGE_HANDLE for the new message.  This handle can be used in subsequent function calls to the fax server, such as ABORT_MESSAGE_FUNCTION, DELETE_MESSAGE, and GET_Q_ENTRIES_INFO.

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 uses the GET_Q_ENTRIES_INFO function to retrieve the MESSAGE_COMPLETION_CODE for the message and then uses the  DELETE_MESSAGE function to delete the completed message.


XML Interface:
The CONTENT_DATA tag is used instead of the CURRENT_FILESPEC tag when referencing local files.  The CONTENT_DATA tag is included in the XML, and contains the content of the file, encoded in base64.  See the XML example below.  For more information, see Working with Files in the CAS XML Interface.

  Type Max Size Multiple Allowed
Function N/A No

Example #1 (ActiveX Interface):
function SendFax()
  {
  var Tl, Sl, StatusNum;

  Tl = CAS.New();
  CAS.AddTag(Tl,"SEND_MESSAGE","");
  CAS.AddTag(Tl,"REGISTERED_NAME","Webclient");
  CAS.AddTag(Tl,"REGISTERED_PASSWORD","");
  CAS.AddTag(Tl,"TRANSFER_TYPE",0);  // 1= EMAIL, 0=FAX
  CAS.AddTag(Tl,"SUBJECT","Subject");

  Sl = CAS.CreateSection(Tl,"RECEIVER_ADDRESS","555-123-1234");
    CAS.AddTag(Sl,"RECEIVER_NAME","Recipient 1");
  CAS.CloseSection(Sl);

  Sl = CAS.CreateSection(Tl,"RECEIVER_ADDRESS","555-456-5678");
    CAS.AddTag(Sl,"RECEIVER_NAME","Recipient 2");
  CAS.CloseSection(Sl);

    // Send a text cover message

  Sl = CAS.CreateSection(Tl,"CONTENT_PART",2);
    CAS.AddTag(Sl,"CONTENT_TYPE",1);
    CAS.AddTag(Sl,"CONTENT_DATA","This is my cover text!");
  CAS.CloseSection(Sl);

    // Send a web page by referencing a URL.  The CONTENT_TYPE
    // is set to HTML, but COPY_ATTACHMENT is 0 so the
    // CURRENT_FILESPEC is treated as a URL, not a file name.

  Sl = CAS.CreateSection(Tl,"CONTENT_PART",3);
    CAS.AddTag(Sl,"CONTENT_TYPE",12);
    CAS.AddTag(Sl,"ORIGINAL_FILENAME","*.html");
    CAS.AddTag(Sl,"CURRENT_FILESPEC", "http://casdev.faxback.com");
    CAS.AddTag(Sl,"COPY_ATTACHMENT",0);
  CAS.CloseSection(Sl);

    // Send a Word .DOC file that's saved on this computer
Sl = CAS.CreateSection(Tl,"CONTENT_PART",3);     CAS.AddTag(Sl,"CONTENT_TYPE",0);
    CAS.AddTag(Sl,"ORIGINAL_FILENAME","TestFile.doc");
    CAS.AddTag(Sl,"CURRENT_FILESPEC","c:\\TestFile.doc");
    CAS.AddTag(Sl,"COPY_ATTACHMENT",1);
  CAS.CloseSection(Sl);
    // Send a .TIF file that's saved on the fax server (set // COPY_ATTACHMENT to 0)
  Sl = CAS.CreateSection(Tl,"CONTENT_PART",3);
    CAS.AddTag(Sl,"CONTENT_TYPE",0);
    CAS.AddTag(Sl,"CURRENT_FILESPEC","c:\\docs\\FaxInfo.tif");
    CAS.AddTag(Sl,"COPY_ATTACHMENT",0);
  CAS.CloseSection(Sl);
// Send message on this already open session Tl = CAS.Send(cInst,Tl); StatusNum = parseInt(CAS.GetTag(Tl,"STATUS_NUM",0)); if (StatusNum == 0) { // The message handle is in the return taglist // MsgHandle = parseInt(CAS.GetTag(Tl,"MESSAGE_HANDLE",0)); } CAS.Delete(Tl); return(StatusNum); }

Example #2 (XML Interface):
function SendFax()
  {
  var Tl, StatusNum;

  Tl = xmlTlNew();
  xmlTlAddTag(Tl,"SEND_MESSAGE","");
  xmlTlAddTag(Tl,"REGISTERED_NAME","Webclient");
  xmlTlAddTag(Tl,"REGISTERED_PASSWORD","");
  xmlTlAddTag(Tl,"TRANSFER_TYPE",0);  // 1= EMAIL, 0=FAX
  xmlTlAddTag(Tl,"SUBJECT","Subject");

  xmlTlCreateSection(Tl,"RECEIVER_ADDRESS","555-123-1234");
    xmlTlAddTag(Tl,"RECEIVER_NAME","Recipient 1");
  xmlTlCloseSection(Tl);

  xmlTlCreateSection(Tl,"RECEIVER_ADDRESS","555-456-5678");
    xmlTlAddTag(Tl,"RECEIVER_NAME","Recipient 2");
  xmlTlCloseSection(Tl);

    // Send a text cover message

  xmlTlCreateSection(Tl,"CONTENT_PART",2);
    xmlTlAddTag(Tl,"CONTENT_TYPE",1);
    xmlTlAddTag(Tl,
                "CONTENT_DATA",
                FBX.base64_encode("This is my cover text!"));
  xmlTlCloseSection(Tl);

    // Send a web page by referencing a URL.  The CONTENT_TYPE
    // is set to HTML, COPY_ATTACHMENT is set to 0, and
    // CURRENT_FILESPEC is set to the URL.

  xmlTlCreateSection(Tl,"CONTENT_PART",3);
    xmlTlAddTag(Tl,"CONTENT_TYPE",12);
    xmlTlAddTag(Tl,"ORIGINAL_FILENAME","*.html");
    xmlTlAddTag(Tl,"CURRENT_FILESPEC", "http://casdev.faxback.com");
    xmlTlAddTag(Tl,"COPY_ATTACHMENT",0);
  xmlTlCloseSection(Tl);

    // Send a Word .DOC file that's saved on this computer

  xmlTlCreateSection(Tl,"CONTENT_PART",3);
    xmlTlAddTag(Tl,"CONTENT_TYPE",0);
    xmlTlAddTag(Tl,"ORIGINAL_FILENAME","TestFile.doc");
    xmlTlAddTag(Tl,
                "CONTENT_DATA",
                FBX.base64_encode_from_file("c:\\TestFile.doc"));
  xmlTlCloseSection(Tl);

    // Send a .TIF file that's saved on the fax server (set
    // COPY_ATTACHMENT to 0)
xmlTlCreateSection(Tl,"CONTENT_PART",3); xmlTlAddTag(Tl,"CONTENT_TYPE",0); xmlTlAddTag(Tl,"CURRENT_FILESPEC","c:\\docs\\FaxInfo.tif"); xmlTlAddTag(Tl,"COPY_ATTACHMENT",0); xmlTlCloseSection(Tl); var responseXML = xmlTlSend(Tl, "\\\\CASDEV\\NETSATISFAXTION", "NETSATISFAXTION", 2, "http://casdev.faxback.com/cgi-bin/casxml.asp"); StatusNum = parseInt(xmlTlGetTag(responseXML,"STATUS_NUM")); if (StatusNum == 0) { // The message handle is in the response XML // Msg = parseInt(xmlTlGetTag(responseXML,"MESSAGE_HANDLE")); } return(StatusNum); }

See Also:
Send Message, Send and Track Message, GET_Q_ENTRIES_INFO, RECEIVER_ADDRESS, CONTENT_PART, SCHEDULE, TEMPLATE_NAME