| 
	
		| 
		
			|  | SoftTree Technologies Technical Support Forums
 |  |  
	
		| 
	
	
	
		| Author | Message |  
		| MichaelV 
 
 
 
 
			
				| Joined: 21 Nov 2007 Posts: 15
 Country: Singapore
 |  
 | 
			
				|  Bug in MailSend |   |  
				| Hi All, 
 I'm testing some code that goes like this.
 
 
 Dim sErrorString, string
 
 
 set(sErrorString,"Some error")
 
 Then I do this
 
 MailSend("someuser@email.com", "","someuser2@email.com", "Test Error", "Test Message")
 I get an email with subject "Test Error" and body "Test Message"
 
 If I do this
 MailSend("someuser@email.com", "","someuser2@email.com", sErrorString, "Test Message")
 
 I get an email with subject "=?ISO-8859-1?Q?Some20Error"
 and body "Test Message"
 
 Anybody has any idea why?
 apparently as long as I use a variable as a subject I'll get this weird format.
 A variable as the body of the email is okay.
 
 The reason why I need the subject to be a variable, is that the organisation has an email to SMS gateway and they
 convert the subject line to the SMS message. If I ask them to change it to the body, lots of other stuff needs to change
 so unlikely to happen.
 
 |  |  
		| Wed Nov 21, 2007 5:58 am |     |  
		|  |  
		| SysOp Site Admin
 
 
 
 
			
				| Joined: 26 Nov 2006 Posts: 7990
 
 |  
 | 
			
				|   |   |  
				| The sErrorString value contains some symbols inappropriate for a single line email subject. These symbols seem to get encoded and appear later as "=?ISO-8859-1?Q?Some20Error" 
 How do you populate the value of this variable?
 
 |  |  
		| Wed Nov 21, 2007 9:29 am |     |  
		|  |  
		| MichaelV 
 
 
 
 
			
				| Joined: 21 Nov 2007 Posts: 15
 Country: Singapore
 |  
 | 
			
				|   |   |  
				| Actually exactly as I stated. 
 I do a case statement after calling an external program and getting
 snippet of the code in question
 
 RunAndWait( sCommand,sBasePath ,0 , sprocessid )
 ProcessGetExitCode( sExitCode )
 
 ChooseCase( sExitCode, Done1 )
 Case( 0 )
 // No error
 Case( 1 )
 set(sErrorString,"General error in file copy")
 Case( 2 )
 set(sErrorString,"Destination not a directory")
 Case( 3 )
 set(sErrorString,"Maximum symlink level exceeded")
 .
 .
 .
 and so on until
 
 Dim sMessage, string
 Set(sMessage,"File Transfer Failed for ")
 Concat(sMessage,sToday_file_name,sMessage)      // today file name is set much earlier in the script
 Concat(sMessage," with error = ",sMessage)
 Concat(sMessage,sErrorString,sMessage)
 MailSend( "x@test.com", "", "x@test.com", sMessage, sMessage )
 
 
 Now at this stage, the email body is correct the subject is that strange string.
 ie
 the Subject becomes
 =?ISO-8859-1?Q?File20Transfer20Failed20for .....
 
 The body of the email is
 File Transfer Failed for filename with error = file not found     (for example.. error depends on what exactly is the return code)
 
 The file name in the above of the sort "something.20071125.cvs.pgp" in case it makes a difference. Pretty much the first part ofthe
 script just generates the date and creates the file name.
 
 |  |  
		| Thu Nov 22, 2007 3:55 am |     |  
		|  |  
		| SysOp Site Admin
 
 
 
 
			
				| Joined: 26 Nov 2006 Posts: 7990
 
 |  
 | 
			
				|   |   |  
				| I see 2 potential issue here 
 1. You are not sending
 MailSend("someuser@email.com", "","someuser2@email.com", sErrorString, "Test Message")
 you are doing
 MailSend( "x@test.com", "", "x@test.com", sMessage, sMessage )
 
 This sMessage can be potential a very long value, much longer then allowed for an email subject, how it will be handled the is really unpredictable.
 
 2. The subject contains special symbols like file name followed by "=" symbol and by date with backslashes, all of which resembles and URL link with parameters.
 
 |  |  
		| Thu Nov 22, 2007 10:57 am |     |  
		|  |  
		| MichaelV 
 
 
 
 
			
				| Joined: 21 Nov 2007 Posts: 15
 Country: Singapore
 |  
 | 
			
				|   |   |  
				| My question as I first stated is on the subject. Whether I do the first or second mailsend command should not make a difference.
 
 Okay did more tests.
 
 and since you want to reduce the error impossibility if the mailbody is text or variable. I changed it back to a simple text.
 
 Set(sMessage,"aaaaabbbbbcccccdddddeeeeefffffggggghhhhhiiiiijjjjjkkkkklllllmmmmmnnnnoooo")
 MailSend("x@test.com","","x@test.com",sMessage,"Text")
 I get
 Subject: aaaaabbbbbcccccdddddeeeeefffffggggghhhhhiiiiijjjjjkkkkklllllmmmmmnnnnoooo
 
 The email subject comes across correctly. So that is a string of approx 15x5 or 75 characters.
 Length of string is not triggering this problem.
 
 
 If I do
 Set(sMessage,"aaaaabbbbbcccccdddddeeeeefffffggggghhhhhiiiiijjjjjkkkkklllllmmmmmnnnn=t")
 MailSend("x@test.com","","x@test.com",sMessage,"Text")
 I get
 Subject: =?ISO-8859-1?Q?aaaaabbbbbcccccdddddeeeeefffffggggghhhhhiiiiijjjjjkkkkklllllmmmmmnnnn=3D=
 t?=
 
 If I do
 Set(sMessage, "aaaaabbbbbcccccdddddeeeeefffff=t")
 MailSend("x@test.com","","x@test.com",sMessage,"Text")
 I get
 Subject: =?ISO-8859-1?Q?aaaaabbbbbcccccdddddeeeeefffff=3Dt?=
 
 If I do
 Set(sMessage, "a=t")
 MailSend("x@test.com","","x@test.com",sMessage,"Text")
 I get
 Subject: =?ISO-8859-1?Q?a=3Dt?=
 
 If I use a normal email client or manually use telnet to simulate an smtp email.
 and I put a=t in the subject I get
 Subject: a=t
 
 
 
 So in short for some strange reason, if you put an = sign in any variable MailSend will always interpreted it wrong.
 It has nothing to do with length of string. Just simply having an = sign is sufficient.
 This should not happen. Normal emails can have =?!@ and most other symbols in the subject line.
 
 What makes this more interesting that the same variable has no effect on the body part but
 only the subject part of MailSend.
 
 Somehow the code is written to interpret this differently.
 
 |  |  
		| Thu Nov 22, 2007 9:57 pm |     |  
		|  |  
		| SysOp Site Admin
 
 
 
 
			
				| Joined: 26 Nov 2006 Posts: 7990
 
 |  
 | 
			
				|   |   |  
				| Change email encoding/sending format that you currently have in the 24x7 option to "plain text" MIME encoding. or whatever encoding is supported by your email client or server. With the right set of options you will get what you want. 
 |  |  
		| Fri Nov 23, 2007 10:36 am |     |  
		|  |  
		| kokhong 
 
 
 
 
			
				| Joined: 29 Nov 2007 Posts: 2
 
 |  
 | 
			
				|   |   |  
				| Both options had been tested with the same results. It appears that 24x7 can't handle the "=" char in the subject line. Please verify. 
 We'll be testing the Java version to see if there's any difference.
 
 |  |  
		| Thu Nov 29, 2007 6:16 am |     |  
		|  |  
		| SysOp Site Admin
 
 
 
 
			
				| Joined: 26 Nov 2006 Posts: 7990
 
 |  
 |  |  
		| Thu Nov 29, 2007 12:55 pm |     |  
		|  |  
		| MichaelV 
 
 
 
 
			
				| Joined: 21 Nov 2007 Posts: 15
 Country: Singapore
 |  
 | 
			
				|   |   |  
				| Haven't tried to replace the DLL as suggested. 
 Before your reply I was trying out the Java version.
 
 I was using a single line script that goes
 
 Mail.mailSend("michael@test.com","","michael@test.com","Test Subject","Test Message");
 
 
 I've turn on tracing and strangely when I use the debugger "Unexpected script error"
 
 From the tracing if I run the script as normal
 2007-11-30 14:17:34,386 [Job #6 - Test] DEBUG com.softtreetech.jscheduler.business.runner.javascript.JavaScriptThreadImpl - evaluateScript(): script terminated with exception: org.mozilla.javascript.EcmaError: TypeError: mailSend is not a function.
 
 I was reading the forum and somebody suggest Mail.send ( .....
 with that I also get
 2007-11-30 14:15:10,522 [Job #6 - Test] DEBUG com.softtreetech.jscheduler.business.runner.javascript.JavaScriptThreadImpl - evaluateScript(): script terminated with exception: org.mozilla.javascript.EcmaError: TypeError: Send is not a function.
 
 
 what is the correct syntax?
 
 The email address matches the one set in the options->email options.
 Tried with and without passwords both same errors.
 
 |  |  
		| Fri Nov 30, 2007 2:20 am |     |  
		|  |  
		| MichaelV 
 
 
 
 
			
				| Joined: 21 Nov 2007 Posts: 15
 Country: Singapore
 |  
 | 
			
				|   |   |  
				| I've tried the dll that you mentioned. 
 Yes with that dll a subject string "a=t" as stated above  works as the email subject now correctly shows up as a=t
 
 |  |  
		| Fri Nov 30, 2007 2:23 am |     |  
		|  |  
		| SysOp Site Admin
 
 
 
 
			
				| Joined: 26 Nov 2006 Posts: 7990
 
 |  
 | 
			
				|   |   |  
				| The correct syntax for JavaScript is to use Mail.send('michael@test.com','','michael@test.com','Test Subject','Test Message');
 
 The error message indicates that "send" was entered as "Send" - JavaScript is case sensitive and Send was not recognized as a valid method. In comparison both JAL and VBScript are case insensitive.
 
 
 Small suggestion: use Edit/Insert... commands to paste the correct syntax
 
 |  |  
		| Fri Nov 30, 2007 2:38 am |     |  
		|  |  
		| MichaelV 
 
 
 
 
			
				| Joined: 21 Nov 2007 Posts: 15
 Country: Singapore
 |  
 | 
			
				|   |   |  
				| Hi Sysop, 
 Okay thanks for the syntax change. For some reason Mail.mailSend is in the Javascript reference pdf.
 
 Okay now another strange problem.
 With that syntax I get Illegal Address
 
 This is the relevant debug log.
 
 
 2007-11-30 16:07:23,113 [Job #6 - Test] DEBUG com.softtreetech.jscheduler.business.runner.JavaScriptJobRunner - runJob(): script: Mail.send("michael@hantechnology.com.sg", "", "michael@hantechnology.com.sg","test subject", "test message" );
 
 
 2007-11-30 16:07:23,128 [Job #6 - Test] DEBUG com.softtreetech.jscheduler.business.runner.JavaScriptJobRunner - runJob(): starting JavaScript
 2007-11-30 16:07:23,128 [Job #6 - Test] DEBUG com.softtreetech.jscheduler.business.runner.JavaScriptJobRunner - runJob(): job not using user authentication
 2007-11-30 16:07:23,206 [Job #6 - Test] DEBUG com.softtreetech.jscheduler.common.util.FTPUtil - converting pattern:YYYYMMDDHHMM.SS
 2007-11-30 16:07:23,206 [Job #6 - Test] DEBUG com.softtreetech.jscheduler.common.util.FTPUtil - pattern after am/pm processing: YYYYMMDDHHMM.SS
 2007-11-30 16:07:23,206 [Job #6 - Test] DEBUG com.softtreetech.jscheduler.business.runner.javascript.JavaScriptThreadImpl - evaluateScript(): starting jsthread
 2007-11-30 16:07:23,206 [Job #6 - Test] DEBUG com.softtreetech.jscheduler.business.runner.javascript.JavaScriptThreadImpl - evaluateScript(): waiting
 2007-11-30 16:07:23,300 [JavaScript] DEBUG com.softtreetech.jscheduler.business.runner.javascript.JavaScriptThreadImpl - jsthread started
 2007-11-30 16:07:23,519 [JavaScript] DEBUG com.softtreetech.jscheduler.business.runner.javascript.JavaScriptRunner - runScript: JavaScriptRunner
 2007-11-30 16:07:23,597 [JavaScript] DEBUG com.softtreetech.jscheduler.business.J - Mailer
 java.lang.NullPointerException
 at com.softtreetech.jscheduler.business.preferences.AbstractPrefDatabase.open(Unknown Source)
 at com.softtreetech.jscheduler.business.J.<init>(Unknown Source)
 at com.softtreetech.jscheduler.business.runner.javascript.JavaScriptRunner$Mail.send(Unknown Source)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:174)
 at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:197)
 at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:3026)
 at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2164)
 at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:140)
 at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:304)
 at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2769)
 at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2145)
 at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:140)
 at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:149)
 at org.mozilla.javascript.Context.evaluateReader(Context.java:1251)
 at com.softtreetech.jscheduler.business.runner.javascript.JavaScriptRunner.runScript(Unknown Source)
 at com.softtreetech.jscheduler.business.runner.javascript.JavaScriptThreadImpl.run(Unknown Source)
 2007-11-30 16:07:23,722 [JavaScript] DEBUG com.softtreetech.jscheduler.business.J - sendEmailImpl
 javax.mail.internet.AddressException: Illegal address in string ``''
 at javax.mail.internet.InternetAddress.<init>(InternetAddress.java:68)
 at com.softtreetech.jscheduler.business.J.super(Unknown Source)
 at com.softtreetech.jscheduler.business.J.super(Unknown Source)
 at com.softtreetech.jscheduler.business.runner.javascript.JavaScriptRunner$Mail.send(Unknown Source)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:174)
 at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:197)
 at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:3026)
 at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2164)
 at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:140)
 at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:304)
 at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2769)
 at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2145)
 at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:140)
 at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:149)
 at org.mozilla.javascript.Context.evaluateReader(Context.java:1251)
 at com.softtreetech.jscheduler.business.runner.javascript.JavaScriptRunner.runScript(Unknown Source)
 at com.softtreetech.jscheduler.business.runner.javascript.JavaScriptThreadImpl.run(Unknown Source)
 2007-11-30 16:07:23,722 [JavaScript] DEBUG com.softtreetech.jscheduler.business.runner.javascript.JavaScriptThreadImpl - org.mozilla.javascript.WrappedException: Wrapped com.softtreetech.jscheduler.common.SchedException: Illegal address
 2007-11-30 16:07:23,722 [JavaScript] DEBUG com.softtreetech.jscheduler.business.runner.javascript.JavaScriptThreadImpl - jsthread stopped
 2007-11-30 16:07:23,722 [Job #6 - Test] DEBUG com.softtreetech.jscheduler.business.runner.javascript.JavaScriptThreadImpl - evaluateScript(): script terminated with exception: org.mozilla.javascript.WrappedException: Wrapped com.softtreetech.jscheduler.common.SchedException: Illegal address
 2007-11-30 16:07:23,722 [Job #6 - Test] DEBUG com.softtreetech.jscheduler.business.runner.javascript.JavaScriptThreadImpl - evaluateScript(): rethrow instanceOf RhinoException
 2007-11-30 16:07:23,722 [Job #6 - Test] DEBUG com.softtreetech.jscheduler.business.runner.JavaScriptJobRunner - runJob(): wrapped exception:org.mozilla.javascript.WrappedException: Wrapped com.softtreetech.jscheduler.common.SchedException: Illegal address
 2007-11-30 16:07:23,738 [Job #6 - Test] DEBUG com.softtreetech.jscheduler.business.runner.JavaScriptJobRunner - runJob(): stopping local js thread
 
 |  |  
		| Fri Nov 30, 2007 4:08 am |     |  
		|  |  
		| SysOp Site Admin
 
 
 
 
			
				| Joined: 26 Nov 2006 Posts: 7990
 
 |  
 | 
			
				|   |   |  
				| Have you specified the correct email server IP address or name in the Tools/Options? 
 |  |  
		| Fri Nov 30, 2007 11:17 am |     |  
		|  |  
		| MichaelV 
 
 
 
 
			
				| Joined: 21 Nov 2007 Posts: 15
 Country: Singapore
 |  
 | 
			
				|   |   |  
				| Yes Its the correct IP. Same settings as the windows version. 
 |  |  
		| Mon Dec 03, 2007 12:37 am |     |  
		|  |  
		| SysOp Site Admin
 
 
 
 
			
				| Joined: 26 Nov 2006 Posts: 7990
 
 |  
 | 
			
				|   |   |  
				| Make sure the default email account is correct in Tools/Options menu. If it is not, fixed it, otherwise try using different email account for sender and/or recipient and check if the 'invalid address' error is the same when using different accounts 
 |  |  
		| Mon Dec 03, 2007 2:06 am |     |  
		|  |  
		|  |  
  
	| 
 
 | You cannot post new topics in this forum You cannot reply to topics in this forum
 You cannot edit your posts in this forum
 You cannot delete your posts in this forum
 You cannot vote in polls in this forum
 
 |  |  |