I’ve looked through this forum but haven’t found an answer to my question so I’m hoping you can help me.
I’m trying to send a PDF file attached to an email which is using HTML to format the text. I’ve tried using the attachment.filename with the name of where the file is stored but all this does is create an email with the body text in the attachment and doesn’t pick up the existing file at all. I’m using stringtobytes function to map the HTML body text into the email content with content type text/html.
Can anyone tell me if this is possible? Or can I only send text email content if attaching anything?
Where are are putting that file to be loaded is it from local c:\drive or it is inside the webMethods/IS installed directory? If so please keep the file inside any of the packages/pub folder or in the main IS/ root itself and hence give the path in the attachments/filename,then smtp service should pick the file and email it accordingly.
Thanks for your suggestion, however I’ve got it to work now apart from one problem. I need the body text of the email to be html enabled, to do this I create an attachment with contenttype text/html. This works but if I add the pdf attachment all I end up with is a blank email with two attachments, one is a pdf file and the other is a html file. Do you know how I can show the html file in the body of the email?
Thought people might like to know how I got this to work!
getFile - pulls in the file specified into the body
map - body.bytes to attachment.content with contenttype application/pdf
appendToRecordList - attachments to toList and toList to attachments2 (this supposidly appends the values in toList to the record array)
stringToBytes - body to string, bytes to bytes (this converts the html text inserted into the body text into html code compatible with the attachment.content)
map - bytes to attachment.content, contenttype text/html
appendToRecordList - attachments to fromList, toList to attachments (the first line of the attachments table should be held in toList so after this toList should have 2 entries, if you don’t use attachments2 as a separate field you just overwrite the values)
smtp - attachments to attachments
And hey presto it works, well nearly. As you can see from my above post this code results in a blank email with two attachments. So close…
We have tried pdf attachment.
First generate a PDF by thr following steps
and we were suppose to generate the PDF report
Prepare XSLT based on the PDF Report layout.
Pass IS document data in XML format to XSLT to convert to FO format.
Use the FO file to generate the PDF using the pdf:xsltopdf.(custome java service)
Delete the PDF file from the file system after it has been made available to application user.
scenarion 1: (without encoding)
Then pass the PDF-content in bytes to attachment.content of the smtp service
set the attachment.contenttype=application/x-pdf
But when we open the attachment in the mail, we get the error saying cannot read the file as file is damaged
Scenario 2 : ( with encoding)
encode the pdf.content in bytes using the pub.string:base64Encode
Then pass this bytes to attachment.content of the smtp service
set the attachment.contenttype=application/x-pdf
But when we open the attachment in the mail, we get the error saying file is not decoded properly.
You need to pass the PDF content to webMethods service (pub.client:smtp) as an attachment and set the content-type as application/pdf.
For more details please have a look at webMethods Integration Server Built-In Services reference guide.
1st Option :
Load PDF File as Bytes
Send the bytes via smtp service. In the attachments input map the
bytes to content
set contenttype to “application/pdf”
set encoding to “base64”
one more option is to make use of pub.mime.* services to transform PDF to mime stream and then send it via smtp.
The flow is mentioned below :
pub.file:getFile(load as bytes) pub.io:bytesToStream(convert bytes to stream)
pub.mime:createMimeData(it will create a mime data , you can add attachment and email body to it)
pub.mime:addBodyPart(pass the pdf stream generated in 2nd step , for pdf mention ContentType: application/pdf;name=“Test.pdf” , encoding base64)
pub.mime:addBodyPart(pass stream of email body[create an stream of string which you want as mail body and use it here],Content-type: text/plain;charset=UTF8 , encoding: quoted-printable )
pub.mime:getEnvelopeStream(form mime stream)
pub.client:smtp(send it via smtp)
You will get an email with attached PDF and text. In a single instance of mime data you can attach multiple files as well as mail body.
I configured as advised and now getting the error below.
Can you please help.
Thanks
Regards
Phila
Could not run ‘sendEmail_1’
java.lang.ClassCastException: com.wm.util.Values cannot be cast to java.lang.String
java.lang.ClassCastException: com.wm.util.Values cannot be cast to java.lang.String
at pub.clientimpl.smtp(clientimpl.java:354)
at sun.reflect.GeneratedMethodAccessor284.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.wm.app.b2b.server.JavaService.baseInvoke(JavaService.java:406)
at com.wm.app.b2b.server.invoke.InvokeManager.process(InvokeManager.java:650)
at com.wm.app.b2b.server.util.tspace.ReservationProcessor.process(ReservationProcessor.java:39)
at com.wm.app.b2b.server.invoke.StatisticsProcessor.process(StatisticsProcessor.java:49)
at com.wm.app.b2b.server.invoke.ServiceCompletionImpl.process(ServiceCompletionImpl.java:243)
at com.wm.app.b2b.server.invoke.ValidateProcessor.process(ValidateProcessor.java:49)
at com.wm.app.b2b.server.invoke.PipelineProcessor.process(PipelineProcessor.java:171)
at com.wm.app.b2b.server.ACLManager.process(ACLManager.java:303)
at com.wm.app.b2b.server.invoke.DispatchProcessor.process(DispatchProcessor.java:34)
at com.wm.app.b2b.server.AuditLogManager.process(AuditLogManager.java:377)
at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:549)
at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:386)
at com.wm.app.b2b.server.ServiceManager.invoke(ServiceManager.java:238)
at com.wm.app.b2b.server.BaseService.invoke(BaseService.java:221)
at com.wm.lang.flow.FlowInvoke.invoke(FlowInvoke.java:254)
at com.wm.lang.flow.FlowState.invokeNode(FlowState.java:520)
at com.wm.lang.flow.FlowState.step(FlowState.java:389)
at com.wm.lang.flow.FlowState.invoke(FlowState.java:360)
at com.wm.app.b2b.server.FlowSvcImpl.baseInvoke(FlowSvcImpl.java:1052)
at com.wm.app.b2b.server.invoke.InvokeManager.process(InvokeManager.java:650)
at com.wm.app.b2b.server.util.tspace.ReservationProcessor.process(ReservationProcessor.java:39)
at com.wm.app.b2b.server.invoke.StatisticsProcessor.process(StatisticsProcessor.java:49)
at com.wm.app.b2b.server.invoke.ServiceCompletionImpl.process(ServiceCompletionImpl.java:243)
at com.wm.app.b2b.server.invoke.ValidateProcessor.process(ValidateProcessor.java:49)
at com.wm.app.b2b.server.invoke.PipelineProcessor.process(PipelineProcessor.java:171)
at com.wm.app.b2b.server.ACLManager.process(ACLManager.java:303)
at com.wm.app.b2b.server.invoke.DispatchProcessor.process(DispatchProcessor.java:34)
at com.wm.app.b2b.server.AuditLogManager.process(AuditLogManager.java:377)
at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:549)
at com.wm.app.b2b.server.invoke.InvokeManager.invoke(InvokeManager.java:386)
at com.wm.app.b2b.server.ServiceManager.invoke(ServiceManager.java:238)
at com.wm.app.b2b.server.comm.DefaultServerRequestHandler.handleMessage(DefaultServerRequestHandler.java:119)
at com.wm.app.b2b.server.HTTPMessageHandler.process(HTTPMessageHandler.java:156)
at com.wm.app.b2b.server.HTTPDispatch.handleRequest(HTTPDispatch.java:170)
at com.wm.app.b2b.server.Dispatch.run(Dispatch.java:365)
at com.wm.util.pool.PooledThread.run(PooledThread.java:127)
at java.lang.Thread.run(Thread.java:745)
I believe you used 1st approach , this error comes because of body input parameter of “pub.client:smtp” is a required parameter and you have not set any value to it. Set some value for body or map some data then try.