ReferralNet - Delphi API

Sample Code

procedure TmainFrm.sendBtnClick(Sender: TObject);
var
  documentSet: TdocumentSet;
  id: string;
  fs: TFileStream;
  currentUser: string;
  size: Cardinal;
begin
  screen.Cursor := crHourGlass;
  try
    saveSettings();
    outputMemo.lines.clear;
 
    fs := TFileStream.Create(sendFilenameEdit.FileName, fmOpenRead + fmShareDenyWrite);
    try
 
      // build document set
 
      documentSet.recipient := sendRcptEdit.Text;
      documentSet.classification := CLASSIFICATION_SECURE_MESSAGE;
 
      // add slots (optional)
      // these are examples only, slots can have any name/value and are ignored by the server
 
      size := 255;
      setLength(currentUser, size);
      GetUserName(@currentUser[1], size);
      currentUser := strPas(pChar(currentUser));
 
      setLength(documentSet.slots, 1);
      documentSet.slots[0].name := 'generated-by';
      documentSet.slots[0].value := currentUser;
 
      // add document(s)
 
      setLength(documentSet.documents, 1);
 
      // only the filename part is sent (not the full path)
      documentSet.documents[0].filename := sendFilenameEdit.FileName;
 
      // if contenttype isn't supplied, the api will attempt to detect
      documentSet.documents[0].contentType := 'application/octect-stream';
 
      documentSet.documents[0].isEncrypted := false;
      documentSet.documents[0].stream := fs;
 
      // add document slots (optional)
      // these are examples only, slots can have any name/value and are ignored by the server
 
      setLength(documentSet.documents[0].slots, 1);
      documentSet.documents[0].slots[0].name := 'source-filename';
      documentSet.documents[0].slots[0].value := sendFilenameEdit.FileName;
 
      // send it
 
      id := FreferralNet.SendDocumentSet(documentSet);
 
      outputMemo.Lines.Add(id + ' ');
 
    finally
      fs.Free;
    end;
  finally
    screen.Cursor := crDefault;
  end;
end;
 
dev/delphi.txt · Last modified: 2011/06/22 23:53 by markl