Hello!
I'm trying to send email from Java application using a simple script:
Java Code:
// Load the mail library.
load( "mail/maillib" )

// The test main routine to send a mail message
function main()
{
    // Set this for debugging; not in an applet!
    var embedded = 0

    // Make the message object
    var msg = new Message()
    if( this.debug )
                {
                               writeln( "Script.mail(): debug is on" )
        msg.debug = true
                }
    writeln( "Script.mail(): sending email message" )
    msg.setSubject( "Managed objects mail message" )
    writeln( "Script.mail(): setting server" )
    msg.setServer( "M1.catest.local" )
    writeln( "Script.mail(): setting sender" )
    msg.setSender( "monitoring@catest.local", "Monitoring" )
    writeln( "Script.mail(): setting recipient" )
    msg.addRecipient( "servicedesk@catest.local", "ServiceDesk" )
    writeln( "Script.mail(): setting body" )
    msg.setBody( "A message from Managed Objects follows" )
    writeln( "Script.mail(): sending" )
    msg.send()
    writeln( "Script.mail(): the end" )

}
main ()
As a result I got an error message related to maillib.fs
js> Script.mail(): sending email message
Script.mail(): setting server
Script.mail(): setting sender
Script.mail(): setting recipient
Script.mail(): setting body
Script.mail(): sending
TypeError: [JavaPackage javax.mail.Session.getDefaultInstance] is not a function. (scripts/mail/maillib.fs; line 86)
at org.mozilla.javascript.NativeGlobal.constructError (Unknown Source)
at org.mozilla.javascript.NativeGlobal.constructError (Unknown Source)
at org.mozilla.javascript.ScriptRuntime.call(Unknown Source)
at org.mozilla.javascript.Interpreter.interpret(Unkno wn Source)
at org.mozilla.javascript.InterpretedFunction.call(Un known Source)
at org.mozilla.javascript.ScriptRuntime.call(Unknown Source)
at org.mozilla.javascript.Interpreter.interpret(Unkno wn Source)
at org.mozilla.javascript.InterpretedFunction.call(Un known Source)
at org.mozilla.javascript.ScriptRuntime.call(Unknown Source)
at org.mozilla.javascript.Interpreter.interpret(Unkno wn Source)
at org.mozilla.javascript.InterpretedScript.call(Unkn own Source)
at org.mozilla.javascript.InterpretedScript.exec(Unkn own Source)
at com.mosol.Formula.Script.ScriptEcmaScript.eval(Scr iptEcmaScript.java:657)
at com.mosol.Formula.Script.ScriptEngine.eval(ScriptE ngine.java:226)
at com.mosol.Formula.Client.engine.ScriptEngineUI.eva l(ScriptEngineUI.java:76)
at com.mosol.Formula.Client.ui.Automation.DefinitionS criptsPanel.ConsoleButton_actionPerformed(Definiti onScriptsPanel.java:679)
at com.mosol.Formula.Client.ui.Automation.DefinitionS criptsPanel$4.actionPerformed(DefinitionScriptsPan el.java:188)
at javax.swing.AbstractButton.fireActionPerformed(Unk nown Source)
at javax.swing.AbstractButton$Handler.actionPerformed (Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed (Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent( Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(U nknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unkno wn Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectio nPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectio nPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectio nPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(U nknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
It seems like getDefaultInstance method is wrong. I opened mailib.fs and here is what I saw from 83 to 94 line
Java Code:
// Create session
	var props = new java.util.Properties()
	props.setProperty( "mail.smtp.host", this.smtpserver )
	var session = Packages.javax.mail.Session.getDefaultInstance( props, null )
	//
	// The default Session Instance is created once and cannot be updated. - If we are trying to update the
	// smtp host - we need to use Session.getInstance which provides a new session for each call.
	//
	if ( ! ( session.getProperty("mail.smtp.host").equals(new java.lang.String(this.smtpserver)) ) )
	{
		session = Packages.javax.mail.Session.getInstance( props, null )
	}
Should I modify maillib.fs ? Or maybe my initial script is wrong?
Has anybody faced the same problem?

Thank you in advance,
Elena