Forum Discussion

sindhuussanar's avatar
sindhuussanar
Occasional Visitor
11 months ago

Getting error while sending mail with attachment using Groovy script

I am getting below error while executing the test to send an email with attachment. The below Groovy script was used for sending the mail. Please suggest a solution. I have tried using java code as well to send the mail. But I am getting the same error in that case too.

 

Groovy Script :

 

def ant = new AntBuilder()
ant.mail(mailhost:"${emailHost}", messagemimetype:'text/html', subject:"Test Data", tolist:toEmail, cclist:ccEmail){
from(address:"${fromEmail}")
message("Dear User,\r\n\r\n Please find attached the Report\r\n")
attachments(){
fileset(dir:"${filePath}"){
include(name:"${filename}")
}
}
}

 

Error log :

 

Fri Mar 31 01:12:56 UTC 2023: ERROR: An error occurred in the script of the Groovy Script test step [SendMail]:
Fri Mar 31 01:12:56 UTC 2023: ERROR: : java.lang.NoSuchMethodError: 'java.lang.String com.sun.mail.util.MimeUtil.cleanContentType(javax.mail.internet.MimePart, java.lang.String)'
: java.lang.NoSuchMethodError: 'java.lang.String com.sun.mail.util.MimeUtil.cleanContentType(javax.mail.internet.MimePart, java.lang.String)'
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:116)
at groovy.util.AntBuilder.performTask(AntBuilder.java:260)
at groovy.util.AntBuilder.nodeCompleted(AntBuilder.java:220)
at groovy.util.BuilderSupport.doInvokeMethod(BuilderSupport.java:160)
at groovy.util.AntBuilder.doInvokeMethod(AntBuilder.java:170)
at groovy.util.BuilderSupport.invokeMethod(BuilderSupport.java:74)
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:44)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:148)
at Script1.run(Script1.groovy:19)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.runAndGetResult(SoapUIGroovyScriptEngine.java:111)
at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:97)
at com.eviware.soapui.support.scripting.groovy.SoapUIProGroovyScriptEngineFactory$SoapUIProGroovyScriptEngine.run(SoapUIProGroovyScriptEngineFactory.java:98)
at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:159)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.runTestStep(AbstractTestCaseRunner.java:302)
at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.runCurrentTestStep(WsdlTestCaseRunner.java:53)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:192)
at com.eviware.soapui.impl.wsdl.support.AbstractTestCaseRunner.internalRun(AbstractTestCaseRunner.java:1)
at com.eviware.soapui.impl.wsdl.support.AbstractTestRunner.run(AbstractTestRunner.java:130)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.NoSuchMethodError: 'java.lang.String com.sun.mail.util.MimeUtil.cleanContentType(javax.mail.internet.MimePart, java.lang.String)'
at javax.mail.internet.MimeBodyPart.setFileName(MimeBodyPart.java:1351)
at javax.mail.internet.MimeBodyPart.setFileName(MimeBodyPart.java:577)
at org.apache.tools.ant.taskdefs.email.MimeMailer.send(MimeMailer.java:250)
at org.apache.tools.ant.taskdefs.email.EmailTask.execute(EmailTask.java:577)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
... 22 more

No RepliesBe the first to reply