Tuesday 20 September 2016

[Solved] ODI Error while sending mail using Jython code.Caused By: org.apache.bsf.BSFException: exception from Jython: SyntaxError: ("mismatched character '\\n' expecting '''",

We configured ODI send mail functionality using jython code as we have to configure authenticated mail functionality and also specify the port,

Jython code that we used for ODI Send mail.

import smtplib
import java.lang.String
import string
import java.lang as lang
BODY=string.join((
"To: %s" % 'User_Mailid',
"Subject: %s" % 'Mail Subject' ,
"",
'We used a variable for Mail Content'
), "\r\n")
sender = smtplib.SMTP('Mail Host',Port)
sender.set_debuglevel(1)
sender.ehlo()
sender.starttls()
sender.ehlo()
sender.login('Sender mail id','Password)
sender.sendmail('Sender mail id',['User_Mailid'],BODY)
sender.close()

When we executed the procedure for ODI- send mail functionality we got an error as shown in the screen shot.

Error:



Cause: Some mismatched character in the mail content.

Solution:Issue is with the variable that we used to get the count of source and target file count.

We used a refresh variable to get the count .

Issue is with the syntax that used.

we used chr(13)||chr(10) for new line in the variable and jython code is not supporting this type syntax so we replaced that with '\n'  then refreshed the variable and executed the package successfully.





No comments:

Post a Comment