Issue the send attach Pdf file in Email. (Urgent).

Hello folks, i have issue with attach pdf in e-mail using two lib´s: activation.jar and mail.jar. Currently using a platform SOA and am creating the serviceType, then a file don´t is local and yes by message, so far so good.
Already tried in several forums, but without success.
When send the message (pdf file), the program receive a type ContentType (application/octet-stream) and cause the MessageException, below:
MessageException - in Container:
Message: [B@79ffb7f7  /// the service received the pdf file
[09/03/02 12:22:45] ID=dev_ESBTest (info) application/octet-stream *///ContentType of message*
javax.mail.SendFailedException: Sending failed; *///Exception*
nested exception is:
javax.mail.MessagingException: IOException while sending message;
nested exception is:
**javax.activation.UnsupportedDataTypeException: no object DCH for MIME type application/octet-stream**
at javax.mail.Transport.send0(Transport.java:219)
at javax.mail.Transport.send(Transport.java:81)
javax.mail.MessagingException: IOException while sending message;
nested exception is:
javax.activation.UnsupportedDataTypeException: no object DCH for MIME type application/octet-stream
at com.sun.mail.smtp.SMTPTransport.sendMessage (SMTPTransport.java:353)
at javax.mail.Transport.send0 (Transport.java:164)
at javax.mail.Transport.send(Transport.java:81)
With this, it send the e-mail without attach......above my source simple source code.
ServiceType Code:
     protected void SendEmail(XQPart prt, String host, String from, String to) {
          // create some properties and get the default Session
          Properties props = System.getProperties();
          props.put("mail.smtp.host";, host);
          Session session = Session.getInstance(props, null);
          try {
               // create a message
               MimeMessage msg = new MimeMessage(session);
               msg.setFrom(new InternetAddress(from));
               InternetAddress[] address = { new InternetAddress(to) };
               msg.setRecipients(Message.RecipientType.TO, address);
               msg.setSubject("Test Subject.");
               MimeBodyPart bp1 = new MimeBodyPart();
               bp1.setText("Test Text.");
               MimeBodyPart bp2 = new MimeBodyPart();
               m_xqLog.logInformation(prt.getContentType());
               bp2.setContent(prt.getContent(), prt.getContentType());
               bp2.setFileName("teste.pdf";);
               Multipart mp = new MimeMultipart();
               mp.addBodyPart(bp1);
               mp.addBodyPart(bp2);
               msg.setContent(mp);
               msg.setSentDate(new Date());
               Transport.send(msg);
               System.out.println("Email sent successfully!");
          } catch (MessagingException mex) {
               mex.printStackTrace();
               Exception ex = null;
               if ((ex = mex.getNextException()) != null) {
                    ex.printStackTrace();
     }Anybody would can help me, please....
Thanks ....
Paulo Sampei.

Hello Folks, me again. Then the solution about this question above, below:
Solution:
Code 1: Call 2 method passing requirement parameter:
Obs: Always ContentType = application/octet-stream
ByteArrayInputStream attachStream = new ByteArrayInputStream((byte[]) prt.getContent());
//call constructor class:InputStreamDataSource
InputStreamDataSource isds = new InputStreamDataSource("Testepdf.pdf", prt.getContentType(),attachStream);
//call method sendMail(InputStreamDataSource,host,from,to)
sendMail(isds, s_Host, s_SendFrom, s_SendTo);Code 2: Class InputStreamDataSource
     // statement DataSource
     private class InputStreamDataSource implements DataSource {
          private String name;
          private String contentType;
          private ByteArrayOutputStream baos;
          InputStreamDataSource(String name, String contentType,
                    InputStream inputStream) throws IOException {
               int read;               
               this.name = name;
               this.contentType = contentType;
               baos = new ByteArrayOutputStream();
               byte[] buff = new byte[256];               
               while ((read = inputStream.read(buff)) != -1) {
                    baos.write(buff, 0, read);
          public String getContentType() {
               // TODO Auto-generated method stub
               return contentType;
          public InputStream getInputStream() throws IOException {
               // TODO Auto-generated method stub
               return new ByteArrayInputStream(baos.toByteArray());
          public String getName() {
               // TODO Auto-generated method stub
               return name;
          public OutputStream getOutputStream() throws IOException {
               // TODO Auto-generated method stub
               throw new IOException("Cannot write to this read-only resource");
     }Code 3: mehod sendMail(InputStreamDataSource, host, from, to)
     protected void sendMail(InputStreamDataSource attach, String host,
               String from, String to) {
          // create some properties and get the default Session
          Properties props = System.getProperties();
          props.put("mail.smtp.host", host);
          Session session = Session.getInstance(props, null);
          try {
               // create a message
               MimeMessage msg = new MimeMessage(session);
               msg.setFrom(new InternetAddress(from));
               InternetAddress[] address = { new InternetAddress(to) };
               msg.setRecipients(Message.RecipientType.TO, address);
               msg.setSubject("Assunto teste.");
               // create and fill the first message part
               MimeBodyPart bp1 = new MimeBodyPart();
               bp1.setText("Texto teste.");
               // create the second message part
               m_xqLog.logInformation("[ContentType]:[attach] "
                         + attach.getContentType());
               // attach the file to the message
               MimeBodyPart bp2 = new MimeBodyPart();
               bp2.setDataHandler(new DataHandler(attach));
               bp2.setFileName(attach.getName());
               // create the Multipart and add its parts to it
               Multipart mp = new MimeMultipart();
               mp.addBodyPart(bp1);
               mp.addBodyPart(bp2);
               // add the Multipart to the message
               msg.setContent(mp);
               // set the Date: header
               msg.setSentDate(new Date());
               // send the message
               Transport.send(msg);
               System.out.println("Email sent successfully!");
          } catch (MessagingException mex) {
               mex.printStackTrace();
               Exception ex = null;
               if ((ex = mex.getNextException()) != null) {
                    ex.printStackTrace();
     }Thank you very much, forum and bshannon at your tips.
Cheers,
Paulo Sampei.

Similar Messages

  • Trying to attach pdf files to emails I'm sending to myself.  Instead of attaching the file, it copies the text.  I want the file so I can have it on my iPad.  I've been able to do this in the past, but not the last two tries.  What's wrong?  Thanks.

    Trying to attach pdf files to emails I'm sending to myself.  Instead of attaching the file, it copies the text.  I want the file so I can have it on my iPad.  I've been able to do this in the past, but not the last two tries.  What am I doing wrong?  Thanks.

    You aren't doing anything wrong.
    If the PDF is short enough, your iPad Mail app will display the text as part of the mail.
    Actually it is still an attachment.
    Tap and HOLD on the text and you should see options to "Open In..." that will allow you to open the PDF in most PDF readers such as iBooks, GoodReader, etc.

  • Why can't I send a pdf file by email?

    Why can't I send a pdf file by email?

    How are you trying to send it? What happens when you try? What version of Reader?

  • Can no longer attach pdf files into email.

    I recently purchased a new computer with Windows 8.1 as the OS.  Seems that I am no longer able to attach PDF files into any email.  Any clues as to what has gone wrong?

    Thanks for the help.  Seems I had a failed Windows update several weeks past I had forgottent about.  Had to do a restore to the prior date to get back to the right configuration.  Did an online session with Mircosoft, reinitiated the update, and it seems as if the issue is resolved.  We were able to re-test attaching and send pdf files. Seems there is still some slight issue with IE, but you appear to be on the right track about focusing on Web Outlook if the problem continues to surface.  Thanks again.

  • How do I send a pdf file by email

    How do I send a PDF file as an attachment to an email?

    Just like any other file...
    On Sat, Mar 7, 2015 at 12:16 AM, larrys19338374 <[email protected]>

  • Error in attach PDF file into email

    Hi, currently i have problem in sending out email as i try to go through the <b>Offline Interactive PDF Form Using E-Mail</b> and also <b>Uploading and Downloading Files in Web Dynpro Java</b> and then i manage to get the file that i want to upload into the filedownload UI
    but then the problem is i cannot map the context of the FILEDOWNLOAD UI data source to the attachment email
    which is as below the code
    multipart.addBodyPart(messageBodyPart);
    messageBodyPart = new MimeBodyPart();
    messageBodyPart.setDataHandler(new DataHandler(new MemoryDataSource(wdContext.currentContextElement().getPdfSource())));
    messageBodyPart.setFileName(wdContext.currentContextElement().getFileUploadUI().getResourceName());
    messageBodyPart.setHeader("Content-Type","application/pdf");
    multipart.addBodyPart(messageBodyPart);
    message.setContent(multipart);
    Transport.send(message);
    wonder anyone know where is the problem or mistake or anyone has the idea of doing it

    Hi, currently i have problem in sending out email as i try to go through the <b>Offline Interactive PDF Form Using E-Mail</b> and also <b>Uploading and Downloading Files in Web Dynpro Java</b> and then i manage to get the file that i want to upload into the filedownload UI
    but then the problem is i cannot map the context of the FILEDOWNLOAD UI data source to the attachment email
    which is as below the code
    multipart.addBodyPart(messageBodyPart);
    messageBodyPart = new MimeBodyPart();
    messageBodyPart.setDataHandler(new DataHandler(new MemoryDataSource(wdContext.currentContextElement().getPdfSource())));
    messageBodyPart.setFileName(wdContext.currentContextElement().getFileUploadUI().getResourceName());
    messageBodyPart.setHeader("Content-Type","application/pdf");
    multipart.addBodyPart(messageBodyPart);
    message.setContent(multipart);
    Transport.send(message);
    wonder anyone know where is the problem or mistake or anyone has the idea of doing it

  • Sending attached pdf format via email

    Hi,
    i got one requirement. i have one program. When i execute the program it has to send the
    Employee1, Employee2,employee3 data to Manager1 email id via email. The employee1, employee2, employee3 data should be stored in one folder and send it via email. I can send it individually like employee1 data manager1,again employee2 data to manager1 and again employee3 data to manager1.
    But what i want is i have to store all these three pdf data  in one folder and send at one time.
    similarly i have manager2,manager3...under managers some employess are there?
    is it possible? if yes, could you please help me in this regard? Thanks in advance.

    HI,
    Please find below sample code..it may help you..but you need to do bit modification
    DATA : LS_DOCDATA LIKE SODOCCHGI1,
             LT_DOCDATA TYPE STANDARD TABLE OF SODOCCHGI1,        " Table for subject
             LS_CONTENTS_MSG LIKE SOLISTI1,
             LT_CONTENTS_MSG TYPE STANDARD TABLE OF SOLISTI1,     " table for attachement
             LS_PACKING_LIST LIKE SOPCKLSTI1,
             LT_PACKING_LIST TYPE STANDARD TABLE OF SOPCKLSTI1,   " Table for Document type and length
             LS_OBJECT_HEADER LIKE SOLISTI1,
             LT_OBJECT_HEADER TYPE STANDARD TABLE OF SOLISTI1,     " Table for Header
             LS_CONTENTS_TXT LIKE SOLISTI1,
             LT_CONTENTS_TXT TYPE STANDARD TABLE OF SOLISTI1,      " Table for mail contents
             LS_RECEIVERS LIKE SOMLRECI1,
             LT_RECEIVERS TYPE STANDARD TABLE OF SOMLRECI1,        " Table for receiver,
    Subject line
      LS_DOCDATA-OBJ_LANGU = sy-langu.
      LS_DOCDATA-OBJ_NAME = text-002.
      LS_DOCDATA-OBJ_DESCR = 'bunu'.
      LS_CONTENTS_MSG-LINE = 'BUNOO' .
      APPEND LS_CONTENTS_MSG TO LT_CONTENTS_MSG.
    LS_CONTENTS_TXT-LINE = text-009.
      APPEND LS_CONTENTS_TXT TO LT_CONTENTS_TXT.
      clear LS_CONTENTS_TXT.
    BREAK-POINT.
    Content structure
      LS_PACKING_LIST-TRANSF_BIN = space.
      LS_PACKING_LIST-HEAD_START = 1.
      LS_PACKING_LIST-HEAD_NUM = 0.
      LS_PACKING_LIST-BODY_START = 1.
      DESCRIBE TABLE LT_CONTENTS_TXT LINES LS_PACKING_LIST-BODY_NUM .
      LS_PACKING_LIST-DOC_TYPE = 'RAW'.
      append LS_PACKING_LIST to Lt_PACKING_LIST.
    Create attachment notification
      LS_PACKING_LIST-TRANSF_BIN = 'X'.
      LS_PACKING_LIST-HEAD_START = 1.
      LS_PACKING_LIST-HEAD_NUM   = 1.
      LS_PACKING_LIST-BODY_START = 1.
      DESCRIBE TABLE LT_CONTENTS_MSG LINES LS_PACKING_LIST-BODY_NUM.
      LS_PACKING_LIST-DOC_TYPE   =  'PDF'.
      LS_PACKING_LIST-OBJ_DESCR  =  'PDF ATTACHEMENT'.
      LS_PACKING_LIST-OBJ_NAME   =  'DEMO'.
      LS_PACKING_LIST-DOC_SIZE   =  LS_PACKING_LIST-BODY_NUM * 255.
      APPEND LS_PACKING_LIST TO Lt_PACKING_LIST.
      LS_RECEIVERS-RECEIVER = 'WRITE THE MAIL ID HERE'.
      LS_RECEIVERS-REC_TYPE = 'U'.
      APPEND LS_RECEIVERS TO LT_RECEIVERS.
      LS_RECEIVERS-RECEIVER = 'WRITE THE MAIL ID HERE' TO SEND IN CC FIELD'  .
      LS_RECEIVERS-REC_TYPE = 'U'.
      LS_RECEIVERS-COPY = 'X'.
      APPEND LS_RECEIVERS TO LT_RECEIVERS.
    Send mail
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          DOCUMENT_DATA                    = LS_DOCDATA
         PUT_IN_OUTBOX                    = 'X'
         COMMIT_WORK                      = 'X'
    IMPORTING
      SENT_TO_ALL                      =
      NEW_OBJECT_ID                    =
        TABLES
          PACKING_LIST                     = Lt_PACKING_LIST
      OBJECT_HEADER                    =
       CONTENTS_BIN                     = LT_CONTENTS_MSG
         CONTENTS_TXT                     = LT_CONTENTS_TXT
      CONTENTS_HEX                     =
      OBJECT_PARA                      =
      OBJECT_PARB                      =
          RECEIVERS                        = LT_RECEIVERS
    EXCEPTIONS
      TOO_MANY_RECEIVERS               = 1
      DOCUMENT_NOT_SENT                = 2
      DOCUMENT_TYPE_NOT_EXIST          = 3
      OPERATION_NO_AUTHORIZATION       = 4
      PARAMETER_ERROR                  = 5
      X_ERROR                          = 6
      ENQUEUE_ERROR                    = 7
      OTHERS                           = 8
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Regards
    Ansumesh

  • I've been attaching pdf's to emails forever.  All of the sudden my pdf files won't attach to any email.  I have tried from home, work, different providers, etc.  Nothing is working.  What could the problem be?

    I have been attaching pdf files to emails forever.  All of the sudden my pdf files won't attach to an email.  It just sits there and spins like it's trying to attach but quits half way through.  What could the problem be?

    Please try repairing Reader installation on your machine. Do you get any error message while attaching the pdf file?
    Regards,
    Deepak

  • Downloading attached zip file from emails using safari

    How to download, and where will be the downloaded attached zip file in email be stored using safari? How to open and save the zip file attached to the email? Do you need an app to open and store the zip file?

    The app GoodReader (I don't know if there are any free apps that can also do it) can be used to zip and unzip email attachments
    press and hold the zip file in your email - after a couple of seconds you should get a popup, with one option being 'Open in GoodReader' which you should select
    GoodReader should then open with the zip file listed under My Documents
    select Manage Files on the right-hand side of GoodReader, select the zip file, and touch the Unzip button that appears on the right
    You should also be able to download zip files directly into GoodReader by typing the URL in its Wed Downloads sectio.

  • I have tried a lot to find an app or some way in email to attach multiple of pdf files in one email. I could not find anything that sends multiple pdf file in one email and still keeping the file in simple pdf format for the recipient.

    I have tried a lot to find an app or some way in email to attach multiple of pdf files in one email. I could not find anything that sends multiple pdf file in one email and still keeping the file in simple pdf format for the recipient.

    I am not aware of a way except for photos that allows you to select multiple files in an email. I even checked settings in the Adobe Reader app, and it does not show that ability.

  • Starting yesterday I can scan a pdf file in from the scanner and can not send a pdf in an email attachment

    Starting yesterday I can scan a pdf file in from the scanner and can not send a pdf in an email attachment.  What happened?  Windows 8

    Adobe Reader can't scan documents. What software do you use?

  • Sending a pdf file as an attachment in the workflow.

    Dear All,
    In my workflow , i want to send a pdf file as an attachment.I know this topic has been discussed in earlier threads but i couldn't make out from them.So plz if possible do give simple detailed solution for better understanding.
    Regards,
    Geet Bijlani.

    The SOFM Object should be created as follows.
    1) get the relationship using class 'CL_BINARY_RELATION' using method 'READ_LINKS'
    2) get the instance ID from INSTID_B
    3) split the value according to the keyfields in SOFM and create object SOFM
    4) bind each object to the Workitem or Email.
    with regards,
    Sudhahar R

  • Can anyone tell me how to send a PDF file so that it opens up in the body of the email itself? Thanks

    Can anyone tell me how to send a PDF file so that it opens up in the body of the email itself? Thanks

    That is a function of the recipient's e-mail software understanding what your software sent.  If it doesn't it will always show as an icon or attachment.   It is also a function of both your internet provider and their internet provider accepting messages of that size, and a function of their download attachment settings in their e-mail program.  There is no way to guarantee it will appear inline in the attachment.   The best you can do is attach with Windows Friendly format.  To do that, use the attach toolbar icon that looks like a paperclip, (View menu -> Customize toolbar if invisible) on Mac OS X Mail when composing the message.   A checkbox appears in the file dialog box's bottom to make it Windows friendly when you navigate to pick the PDF file.  That makes it as universally compatible as possible.  It still may not appear inline, but at least you are less likely to be incompatible.

  • How can I embed a form on my website and set up a submit button so that when people fill out and click Submit, the filled form will be emailed to me as an attached pdf file?

    How can I embed a form on my website and set up a submit button so that when people fill out and click Submit, the filled form will be emailed to me as an attached pdf file?
    Thank you!

    Hi;
    That is not a workflow that is supported by the Adobe forms solutions at this time.
    Thanks,
    Josh

  • How do I email an attached pdf file to stationary templates in mail.

    How do I email an attach PDF file using the stationary templates in mail on lion.
    I attached the PDF but when try to send it I get back a dialog box that sez:
    "This message cannot be sent because it uses stationery and contains attachments that are not images. Messages with stationery cannot contain attachments that aren’t images. You can cancel and return to editing the message or remove the stationery in order to send." My choice is to cancel or remove stationary.
    Is there a third party solution? Any suggestion?

    No
    Envoyé depuis Molto pour iPad
    De: pwillener
    Envoyé: jeudi, février 12, 2015 07:14 AM
    À: René Allamelle
    Objet:  how do I compress a large pdf file to fit in an email?
    how do I compress a large pdf file to fit in an email?
    created by pwillener in Adobe Acrobat.com Services - View the full discussion
    But generally it is never a good idea to send e-documents as email attachments.  Better use a file sharing service (Acrobat.com, Dropbox, Google Drive, Microsoft OneDrive, ..), upload the document, then send the shared download link via email.
    If the reply above answers your question, please take a moment to mark this answer as correct by visiting: https://forums.adobe.com/message/7187079#7187079 and clicking ‘Correct’ below the answer
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page:
    Please note that the Adobe Forums do not accept email attachments. If you want to embed an image in your message please visit the thread in the forum and click the camera icon: https://forums.adobe.com/message/7187079#7187079
    To unsubscribe from this thread, please visit the message page at , click "Following" at the top right, & "Stop Following"
    Start a new discussion in Adobe Acrobat.com Services by email or at Adobe Community
    For more information about maintaining your forum email notifications please go to https://forums.adobe.com/thread/1516624.

Maybe you are looking for

  • Not getting all my bytes from inout stream.

    hi, i'm writing an i-appli that interacts with a java web server. my problem is that i'm not getting all of my bytes through to the phone. actually i'm using an emulator right now. when i use the real phone i set content length on the server side and

  • Standby Database - from READ-ONLY to Managed Recovery

    We have a standby database set up for our production environment. We are able to switch logfile on production and perform the managed recovery and then switch over to READ-ONLY mode. However, when the database is in READ-ONLY mode...I cannot close it

  • Cannot install AIR 3.4 on Mac OS X 10.8.1

    I have a new install of Mac OS X 10.8.1 and cannot get Adobe AIR to install. I previously could not get it to install under 10.8 either. Logs that I've found are the following: 8/30/12 4:04:47.277 PM Adobe AIR Installer[6985]: Runtime Installer begin

  • Empty folder in the hard drive

    hi everyone, does someone here have a clue why do i have this folder on my main hard drive? i'm using os x lion (10.7) mid 2010

  • 24p AVCHD

    Though I'm going to upgrade within a couple months, I'm currently using a Panasonic HDC-SD9 for a few projects, and like shooting in 24p mode. The AVCHD editing modes in PE7 do not offer a "Full HD" mode with 23.976 timebase. It instead offers a 29.9