This code wroked welll before, I have not changed a thing, and its not working now. I am getting the (!success) error message. I have not tried the plugin during the last few versions..
//print the current form as pdf into a variable
var success = plugins.pdf_output.startMetaPrintJob()
if (success)
{
controller.print(false,false,plugins.pdf_output.getPDFPrinter());
}
var thePdf = plugins.pdf_output.endMetaPrintJob()
var attachment1 = plugins.mail.createBinaryAttachment(‘TSE Sales Form.pdf’,thePdf);
var succes = plugins.mail.sendMail(globals.Text6,currentuserglobal_to_employee_by_id.email,“TSE Sales Order”+’ '+product_sales_order_number,globals.Text5,globals.Text7,null,new Array(attachment1));
if (!succes)
{
plugins.dialogs.showWarningDialog(‘Alert’,‘Failed to send email’,‘OK’);
}
// Clear Globals
globals.Text6 = null;
globals.Text5 = null;
globals.Text7 = null;
If you run this on your server check the servoy server log (Servoy-admin pages).
Only then you can see what is going on.
Also running the client with Webstart console open will show a lot of debugging information.
For all we know it could be a bad email address and the SMTP server rejected it.
well, Looks like I found the cookies. If I don’t enter any text (globals.Text5) into the message body, I get the error. I guess I have always entered text in the past.
Thanks for the help
Also running the client with Webstart console open will show a lot of debugging information
An update on using multiple SMTP accounts with the Send Mail plugin.
It works brilliantly - although I’ve lost some hair in the process so here’s some gotcha’s to avoid.
1
Assuming you are getting the SMTP account details from stored fields (and not hard coding) be sure to close the inverted commas “” after the = sign
Quote:
var authorization = new Array(“mail.smtp.host=” + smtp mail server, “mail.smtp.auth=true”, “mail.smtp.username=” + user name, “mail.smtp.password=” + password);
2
Send Mail will fail if Subject or MsgText are empty. Either error trap or add a space ie: MsgText += ’ ’
3
Send Mail failure messages can be found in the Server Log.
Finally, double-check that your Users have entered their passwords correctly before you spend 2hrs debugging & testing your code trying to work out why its failing !!
Another tip is to use a try/catch block to show the real error message.
Something like this:
//print the current form as pdf into a variable
var success = plugins.pdf_output.startMetaPrintJob()
if (success)
{
controller.print(false,false,plugins.pdf_output.getPDFPrinter());
}
var thePdf = plugins.pdf_output.endMetaPrintJob()
var attachment1 = plugins.mail.createBinaryAttachment('TSE Sales Form.pdf',thePdf);
try
{
var succes = plugins.mail.sendMail(globals.Text6,currentuserglobal_to_employee_by_id.email,"TSE Sales Order"+''+product_sales_order_number,globals.Text5,globals.Text7,null,new Array(attachment1));
if (!succes)
{
plugins.dialogs.showWarningDialog('Alert','Failed to send email','OK');
}
} catch(theErr)
{
plugins.dialogs.showWarningDialog('Alert','Failed to send email\nError:' + theErr,'OK');
}
// Clear Globals
globals.Text6 = null;
globals.Text5 = null;
globals.Text7 = null;
This is not a meant to be negative in any way. I know how hard it is to develop, and document and ever evolving development enviorment. I realize where the emphasis in now with the product, and encourage the feature devopment over all.
This software targets FMP users based on simplicity, "not having to write SQL / Java / HTML."etc..
Well to harness the power, you really need to learn all the above. It is hard to find the time, to develop a new system, keep up with the bandaids on the old, and learn a few languages.
With this in mind, searching the forum is the best place for information like the above post. It is nearly impossible to search for specific topics without having to dig though hundreds of threads.
I hate posting silly questions, especially ones that have been asked before. I am confident that there will be a sample / help index that can be easily searched for accomplishing fundemental processes.
Between the documentation, the magazine, forum, etc its all there, just kinda hard to find at times at times based on indexes keywords, etc…
I look forward to the day I can really grasp the java enviorment, and spend less time coding. Fortunatey, Servoy had allowed my to bridge the gap between FMP and 3 tier architecture.
var authorization = new Array(“mail.smtp.host=” + smtp mail server, “mail.smtp.auth=true”, “mail.smtp.username=” + user name, “mail.smtp.password=” + password);
Is it possible to change the smtp mail port from its default 25 to something else? One of my clients run his stmp server on a different port and want to use that one
ahmad:
Is it possible to change the smtp mail port from its default 25 to something else? One of my clients run his stmp server on a different port and want to use that one.
I posted exactly this question to Servoy Support and got the response, “No, not at this time.”