Hi all,
I have created a Flow service to send email in HTML format and it is working fine, But now i have to add an attachment(text file) to the email. I am able to send plain text email with attachment but with HTML content, the text file is not getting attached with the email.
services that i am using(in sequence) are :
-
pub.io.stringToStream
-
pub.mime.createMimeData
input(s)
-----mime-header/content-type = text/html
-----mime-header/x-priority = 1
-
pub.mime.addBodyPart
input(s)
-----mimeData = [created in previous step above(2)]
-----content = [created in first step above(1)]
-----contentTyp = text/html
-
pub.mime.getEnvelopStream
input(s)
-----mimeData = [created in previous step above(3)]
-
pub.client.smtp
input(s)
-----to
-----cc
-----subject
-----from
-----mail host
-----mimeStream = [created in previous step above(4)]
-----attachments
-----input(s)
---------contentType=text/html
---------fileName=newFile.txt
---------content=[string value]/[stringToStream for the input]/[stringToBytes for the input]
---------encoding=none
---------charset=none
Please suggest, Thanks in advance.
Abhishek Jain
Hi mahesh,
Thanks for the efforts, but what i want is to send an email with “HTML as body”, and “an attachment attached with that mail”. HTML content is getting emailed perfectly, the only issue is with Attachment.
I am not able to attach the text file or any file(pdf/doc) with the email.
Thanks…
Abhishek Jain
Hi,
When I look at your code for the service pub.client:smtp you are passing both.
--------fileName=newFile.txt
---------content=[string value]/[stringToStream for the input]/[stringToBytes for the input]
But the built in service guide says
"
content - byte, String, or java.io.InputStream Content of the message.
filename - String Name of a local file to be attached to the message. Used only if content is not specified. "
Can you check this if I am not wrong.
Meanwhile attach your package that has your code. Let me have a look at that.
Hi mahesh,
Apologies for replying so late, i got busy in some more critical issue.
- I have tried all the three options for content.
- Filename is provided if we want to provide a predefined name to the content/attachment.
Please find attached the Sample code for the same.
Best regards…
Abhishek
HTMLEmail.zip (10.4 KB)
I think what’s happening is that your use of the pub.client:smtp’s mimeStream parameter is overriding the use of the attachments parameter. What you need to do is make a second pub.mime:addBodyPart call to add your attachment to the mimedata object before the pub.mime:getEnvelopeStream call.
@M@he$h: the 8.2-SP2 Integration Server Built-In Services Reference specifies:
- If you specify attachment/content and attachments/filename, the service uses the value of attachments/filename as the name to assign to the attachment specified by attachment/content.
- If you specify attachments/filename, but not attachment/content, the service attaches the local file specified by attachments/filename.
@erossing.26610 hi,
I am not able to figure out that how can in add Attachment in pub.mime:addBodyPart. Though i have tried two streams one for body and other for attachment, but that is also not working.
Please upload the code if possible.
Thanks !!
Abhishek Jain
Here’s a sample, which works for me. It was created on wM IS version 8.2.2
HTMLEmailWithAttachment.zip (6.29 KB)
HI erossing,
It is working perfectly fine as intended :D, Thanks for the efforts man.
Best regards …
Abhishek Jain