IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.


#TechXchangePresenter
 View Only
Expand all | Collapse all

unable to attach text file in HTML email

  • 1.  unable to attach text file in HTML email

    Posted Thu March 20, 2014 07:52 AM

    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 :

    1. pub.io.stringToStream

    2. pub.mime.createMimeData
      input(s)
      -----mime-header/content-type = text/html
      -----mime-header/x-priority = 1

    3. pub.mime.addBodyPart
      input(s)
      -----mimeData = [created in previous step above(2)]
      -----content = [created in first step above(1)]
      -----contentTyp = text/html

    4. pub.mime.getEnvelopStream
      input(s)
      -----mimeData = [created in previous step above(3)]

    5. 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


    #webMethods
    #Integration-Server-and-ESB
    #webmethods-Protocol-and-Transport


  • 2.  RE: unable to attach text file in HTML email



  • 3.  RE: unable to attach text file in HTML email

    Posted Fri March 21, 2014 06:09 AM

    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


    #webMethods
    #Integration-Server-and-ESB
    #webmethods-Protocol-and-Transport


  • 4.  RE: unable to attach text file in HTML email

    Posted Fri March 21, 2014 07:00 AM

    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.


    #webMethods
    #Integration-Server-and-ESB
    #webmethods-Protocol-and-Transport


  • 5.  RE: unable to attach text file in HTML email

    Posted Mon April 14, 2014 09:24 AM

    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)


    #Integration-Server-and-ESB
    #webMethods
    #webmethods-Protocol-and-Transport


  • 6.  RE: unable to attach text file in HTML email

    Posted Wed April 23, 2014 05:06 PM

    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.

    #webmethods-Protocol-and-Transport
    #Integration-Server-and-ESB
    #webMethods


  • 7.  RE: unable to attach text file in HTML email

    Posted Fri April 25, 2014 09:11 AM

    @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


    #webmethods-Protocol-and-Transport
    #Integration-Server-and-ESB
    #webMethods


  • 8.  RE: unable to attach text file in HTML email

    Posted Fri April 25, 2014 02:39 PM

    Here’s a sample, which works for me. It was created on wM IS version 8.2.2

    HTMLEmailWithAttachment.zip (6.29 KB)


    #Integration-Server-and-ESB
    #webmethods-Protocol-and-Transport
    #webMethods


  • 9.  RE: unable to attach text file in HTML email

    Posted Tue April 29, 2014 10:20 AM

    HI erossing,

    It is working perfectly fine as intended :D, Thanks for the efforts man.

    Best regards …
    Abhishek Jain


    #webMethods
    #webmethods-Protocol-and-Transport
    #Integration-Server-and-ESB