FTP bean does not work on servoy client

Hi there,

I’m using an FTP bean in my solution. The ftp bean was recommended by Servoyians long time before. (I attach the bean herewith)

The bean works some what properly in the developer but sometimes it stops working for unkown reasons.

My problem now is it never works on client and throws an error as attached. I don’t know whether the bean is automatically installed on client or not.

My method uses the following code:

ftpBeanObj = forms.Bean.elements.bean_950;
ftp_host = frmPrefs.ftp_host;
ftp_user_name = frmPrefs.ftp_username;
ftp_password = frmPrefs.ftp_password;
ftpBeanObj.ftpConnect(ftp_host, ftp_user_name, ftp_password);

When it connects the error occurs

Pls help me
Thanks
Ahmad

the problem was that the ftp bean had a funny package name (very short) because of that it wouldn’t load in the client.
fixed this in RC8

I get a similar problem with SMTP bean from http://www.elegantjbeans.com/

It sends email properly in the developer but not in the client.

It just throws an error “Could not perform form method ‘startBroadcast’” when running the method from the client.

It works perfectly in the developer.

Please help!!

Thanks a lot

what code do you exactly use?
Why are you using a smtp bean? Why not use the mail plugin?

Here is my full code

globals.stopBroadcast = 0;
var frmObj = globals.mod_functions_layout("getMainFrmObj", globals.currentRoom);
var frmObjHist = forms.broadcastParent_parentListLink;
frmObjHist.controller.find();
frmObjHist.broadcast_id = frmObj.broadcast_id;
frmObjHist.send_tag     = 1;
frmObjHist.controller.search();
var maxRecords = databaseManager.getFoundSetCount(frmObjHist.foundset);

if (frmObj.email_type == "html") {
   var openingBrace = "<<";
   var closingBrace = ">>";
}
else {
   var openingBrace = "<<";
   var closingBrace = ">>";
}

var mediaFileList = globals.local_functions_admin("createBroadcastAttachment");

var msg  = forms.sysAdmin.elements.bean_1020;
var smtp = forms.sysAdmin.elements.bean_844;
globals.local_functions_admin('setSMTPObj', smtp);
smtp.openConnection();

var successCount = 0;
var failedCount  = 0;
globals.mod_functions_utilities("setProgressionPresets", forms.broadcastSend, 'progress', maxRecords);

for (var i=1; i <= maxRecords; i++) { //******* FOR LOOP 1
   var record = frmObjHist.foundset.getRecord(i);
   if (globals.stopBroadcast == 1) {
      break;
   }
   var emailBody = frmObj.body;

   var relName = "parent_id__broadcast_history_to_parent";
   var toEmail     = record[relName].email;
   var firstName   = record[relName].first_name;
   var lastName    = record[relName].last_name;
   var knownAsName = record[relName].known_as_name;
   var userName    = record[relName].user_name;
   var password    = record[relName].user_password;

   emailBody = utils.stringReplace(emailBody, openingBrace + 'firstname'   + closingBrace, firstName   + '');
   emailBody = utils.stringReplace(emailBody, openingBrace + 'lastname'    + closingBrace, lastName    + '');
   emailBody = utils.stringReplace(emailBody, openingBrace + 'knownasname' + closingBrace, knownAsName + '');
   emailBody = utils.stringReplace(emailBody, openingBrace + 'username'    + closingBrace, userName    + '');
   emailBody = utils.stringReplace(emailBody, openingBrace + 'password'    + closingBrace, password    + '');

   statusDisplay = "<html>sending email to <font color=red>" + toEmail + "</font>
" +
                   "sending email <font color=red>" + i + " of " + maxRecords + "</font>
" +
                   "</html>";
   elements.statusDisplay.text = statusDisplay;
   globals.mod_functions_utilities("increaseProgression", forms.broadcastSend, 'progress', i, "");

   elements.statusDisplay.text = statusDisplay;
   globals.mod_functions_utilities("increaseProgression", forms.broadcastSend, 'progress', i, "");

   fromName     = frmObj.from_name;
   fromEmail    = utils.stringTrim(frmObj.from_email);
   var msgArray = new Array(fromEmail, toEmail, "", "", frmObj.subject, emailBody, frmObj.email_type, mediaFileList);
   globals.local_functions_admin("setEmailMessageObj", msg, msgArray);

   smtp.sendMail(msg); 
   var status = smtp.getStatus();
   if (utils.stringPatternCount(status, "Successfully sent data")) {
      var result = "Sent Successfully";
      frmObjHist.send_tag = 0;
      successCount++;
   }
   else if(utils.stringPatternCount(status, "S: 550")) {
      var result = "No user";
      failedCount++;
   }
   else {
      var result = "Problems";
      failedCount++;
   }
   //record.email_result = status;

} //******* FOR LOOP 1

smtp.closeConnection();

if (globals.stopBroadcast == 1) {
   plugins.dialogs.showErrorDialog( "", "email sending has been terminated");
}
else {
   if (failedCount > 0) {
      plugins.dialogs.showErrorDialog( "", "there are " + failedCount + " emails out of " + 
                                   maxRecords + " have been failed");
   }
   else {
      plugins.dialogs.showInfoDialog( "", "all the emails have been sent");
   }
}

globals.local_functions_admin('setBroadcastResult');
globals.nav_closeFormInDialog();
globals.stopBroadcast = 0;

//************* globals.local_functions_admin(“setEmailMessageObj”, msg, msgArray);

   msgObj    = param1;
   msgParams = param2;
   msgObj.from         = msgParams[0];
   msgObj.to           = msgParams[1]; //(Use comma for multiples)
   msgObj.cc           = msgParams[2];
   msgObj.bcc          = msgParams[3];
   msgObj.subject      = msgParams[4]; 
   msgObj.body         = msgParams[5]; 
   var emailType       = msgParams[6]; 

   if (emailType == "plain") {
      msgObj.contentType  = 'text/plain; charset=us-ascii'; //See RFC 2822
   }
   else {
      msgObj.contentType  = 'text/html; charset=us-ascii'; //See RFC 2822
   }

   msgObj.attachments  = msgParams[7];

//*********** globals.local_functions_admin(‘setSMTPObj’, smtp);

   smtpObj    = param1;
   smtpObj.hostName = global_to_sysadmin.smtp_server;
   if (global_to_sysadmin.smtp_use_authentication == 1) {
      smtpObj.authentication = true;
      smtpObj.userName = global_to_sysadmin.smtp_username;
      smtpObj.password = global_to_sysadmin.smtp_password;
   }

And why aren’t you using the MailPlugin?

Do you have a client where i can connect to and test that mail method?

Hi Johan,

I did not send you a testing client.

But with RC3 this seems to have been fixed.