Send attachment though mail using FM SO_NEW_DOCUMENT_ATT_SEND_API1

Hello Gurus,
Please help me with the mail sending attachment(excel file) using FM SO_NEW_DOCUMENT_ATT_SEND_API1.
Here is the actual problem.
I am using the FM SO_NEW_DOCUMENT_ATT_SEND_API1 in my prog.
My attachment(excel sheet which is taken from internal table) contains the 10 records with one header description and data related to that description.
I am able to send the attachment but the records in the attachment has more than 255 characters nearly 700 character length.
So I spilt up each internal table record(with structure type solisti1) into 3 internal table records and populated it.
It is showing the entire record in the attached file but I am not able to see some fields which are embeded deeply inside the cells.
And they are not having any proper allignment.
Please do help me.
Promise to reward points.
Mac

Here is the sample code....
DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS  2 WITH HEADER LINE.
DATA: OBJHEAD LIKE SOLISTI1   OCCURS  1 WITH HEADER LINE.
DATA: OBJBIN  LIKE SOLISTI1   OCCURS 10 WITH HEADER LINE.
DATA: OBJTXT  LIKE SOLISTI1   OCCURS 10 WITH HEADER LINE.
DATA: RECLIST LIKE SOMLRECI1  OCCURS  5 WITH HEADER LINE.
DATA: DOC_CHNG LIKE SODOCCHGI1.
DATA: TAB_LINES LIKE SY-TABIX.
Creating the document to be sent
DOC_CHNG-OBJ_NAME = 'OFFER'.
DOC_CHNG-OBJ_DESCR = 'Auction of a Picasso jr'.
OBJTXT = 'Reserve price : $250000'.
APPEND OBJTXT.
OBJTXT = 'A reproduction of the painting to be auctioned'.
APPEND OBJTXT.
OBJTXT = 'is enclosed as an attachment.'.
APPEND OBJTXT.
DESCRIBE TABLE OBJTXT LINES TAB_LINES.
READ TABLE OBJTXT INDEX TAB_LINES.
DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
Creating the entry for the compressed document
CLEAR OBJPACK-TRANSF_BIN.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM   = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM   = TAB_LINES.
OBJPACK-DOC_TYPE   = 'RAW'.
APPEND OBJPACK.
Creating the document attachment
(Assume the data in OBJBIN are given in BMP format)
OBJBIN = ' \O/ '. APPEND OBJBIN.
OBJBIN = '     '. APPEND OBJBIN.
OBJBIN = ' / \ '. APPEND OBJBIN.
DESCRIBE TABLE OBJBIN LINES TAB_LINES.
OBJHEAD = 'picasso.bmp'. APPEND OBJHEAD.
Creating the entry for the compressed attachment
OBJPACK-TRANSF_BIN = 'X'.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM   = 1.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM   = TAB_LINES.
OBJPACK-DOC_TYPE   = 'BMP'.
OBJPACK-OBJ_NAME   = 'ATTACHMENT'.
OBJPACK-OBJ_DESCR = 'Reproduction object 138'.
OBJPACK-DOC_SIZE   = TAB_LINES * 255.
APPEND OBJPACK..
Entering names in the distribution list
RECLIST-RECEIVER = '<name>@yahoo.com'.
RECLIST-REC_TYPE = 'U'.
APPEND RECLIST.
RECLIST-RECEIVER = 'DLI-NEUREICH'.
RECLIST-REC_TYPE = 'P'.
APPEND RECLIST.
Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
         DOCUMENT_DATA = DOC_CHNG
         PUT_IN_OUTBOX = 'X'
         COMMIT_WORK   = 'X'
    TABLES
         PACKING_LIST  = OBJPACK
         OBJECT_HEADER = OBJHEAD
         CONTENTS_BIN  = OBJBIN
         CONTENTS_TXT  = OBJTXT
         RECEIVERS     = RECLIST
    EXCEPTIONS
         TOO_MANY_RECEIVERS = 1
         DOCUMENT_NOT_SENT  = 2
               OPERATION_NO_AUTHORIZATION = 4
               OTHERS = 99.
     CASE SY-SUBRC.
       WHEN 0.
         WRITE: / 'Result of the send process:'.
         LOOP AT RECLIST.
           WRITE: / RECLIST-RECEIVER(48), ':'.
           IF RECLIST-RETRN_CODE = 0.
             WRITE 'sent successfully'.
           ELSE.
             WRITE 'not sent'.
           ENDIF.
         ENDLOOP.
       WHEN 1.
     WRITE:
     / 'no authorization to send to the specified number recipients!'.
       WHEN 2.
         WRITE: / 'document could not be sent to any of the recipient'.
       WHEN 4.
         WRITE: / 'no authorization to send !'.
       WHEN OTHERS.
         WRITE: / 'error occurred during sending !'.
     ENDCASE.
Regards,
Pavan.

Similar Messages

  • Formated XL attachment in Mail using FM SO_NEW_DOCUMENT_ATT_SEND_API1.

    Hi All,
    I have a requirement where I need to send formated XL in Email attachment using FM SO_NEW_DOCUMENT_ATT_SEND_API1.
    Yes, there are other convinient ways of doing the same task IXML or CL_BCS but I can't use them.
    The existing code already uses this FM and user claims that earlier it used to work but its not working now.
    The existing code generates an Internal Table for attachment, starting with
    <TABLE style='BACKGROUND-COLOR: #XXXXX
    and ending with </TABLE>.
    The final XL in Email contains this XL file but its not formated, its in the same format as it was in Internal Table.
    I also tried increasing the doc_size field, it did not worked..!!
    Even I am not sure whether it is possible this way.
    I tried searching for some links like,
    SO_NEW_DOCUMENT_ATT_SEND_API1 next line Excel
    but, no luck..!!
    Any input provided by you will certainly help.
    Pls post if I am not clear with my requirement.
    Thanking You All.

    Hi Ankit sharma,
    i think we get nearer to point out whats wrong. But still, i dont know what the actuall problem is.
    Does the file looks different?
    When yes, what is different?
    what do you mean by "The final XL in Email contains this XL file but its not formated, its in the same format as it was in Internal Table."
    For sure it should look like in the internal table. I guess what you see is the raw data. and what is not working is, that this raw data gets interpreted like you want it to be - as an XL file. But this is not a bug of different SAP versions since the email got created successfully.
    It is all a matter of how the attachment gets interpreted. So find the Bug in the File.  Can it be that maybe
    some lines are missing in the attchment
    space is added to the end of the row
    CRLF is added to the file
    dont look at SAP Code. Look at the file. Compare it to a file that got created successfully. what is the difference. if you find it, you will find the missing part in the code.
    Looking at the FM-Interface tells me that BIN is obsolete - give your data to hex instead....
    this makes me think that CRLF sign is added in FILE. since bin-content-table  is same Data-type then TXT-content-table
    regards
    Stefan Seeburger

  • After sending attachment through mail using ABAP program.....

    Hello Experts,
    I am facing a problem to fulfill a requirement.
    My requirement is....sending the data of the internal table to an external mail with attachment(excel format). I have done with this. But when o am opening the excel sheet(attachment) it is showing a message that 'The file you are trying to open is in different format than specified by the file extension'
    I am using the extension 'XLS' and 'RAW ' in the coding for the file formats.
    You can please suggest your solutions if you know or already faced this type of issues.
    Thank you.
    Regards,
    Anand

    Hi,
    The system does not trust you....
    I have the feeling that the file you are sending is a text file with the extension 'XLS'
    If the file is comma separated values (http://en.wikipedia.org/wiki/Comma-separated_values) then
    use the extension 'CSV' if it is a tab separated then use the extension 'TXT' .
    Regards.
    CSV is also good for tab separated  I just checked by a copy of BCS_EXAMPLE_7 and changing:
            i_attachment_type    = 'CSV'                        "#EC NOTEXT

  • Sending an e-mail using java

    Hi,
    I am sending an e-mail using java. It works fine, but I wanted to know if there is any possibility to attach a document, without using a File object. Because I have to write the File object and then delete it at the end. I would like to know if I can use for example a byte [], or something else.
    Thank you very much.
    This is my code, if that helps.
    public static void sendWithAttach(String p_sender, String p_receiver, String p_subject,
    String p_comment, int p_nombrePiecesJoints, HashMap<String, byte[]> p_files) {
    Properties props = System.getProperties();
    props.put("mail.smtp.host", Solapcore.getCurrent().getServletConfig().getServletContext().getInitParameter("SMTP"));
    Session session = Session.getDefaultInstance(props, null);
    MimeMessage sender = new MimeMessage(session);
    MimeBodyPart mbp1 = new MimeBodyPart();
    Multipart mp = new MimeMultipart();
    List<File> listeFiles = new ArrayList<File>();
    try {
    //On assigne to, from, subject, body, priority
    sender.setRecipients(javax.mail.Message.RecipientType.TO,
    InternetAddress.parse(p_receiver, false));
    sender.setFrom(new InternetAddress(p_sender));
    sender.setSubject(p_subject);
    mbp1.setText(p_comment);
    //sender.setPriority(0);
    mp.addBodyPart(mbp1);
    //On attache les documents
    for(Map.Entry<String, byte[]> entry : p_files.entrySet()) {
    MimeBodyPart mbp2 = new MimeBodyPart();
    String fileName = entry.getKey();
    byte [] dataFile = entry.getValue();
    File file = new File(fileName);
    FileOutputStream fos = new FileOutputStream(file);
    fos.write(dataFile);
    mbp2.attachFile(file);
    mbp2.setFileName(fileName);
    mp.addBodyPart(mbp2);
    listeFiles.add(file);
    sender.setContent(mp);
    Transport.send(sender);
    }catch(MessagingException mex) {
    mex.printStackTrace();
    }catch(FileNotFoundException fnf) {
    fnf.printStackTrace();
    }catch(IOException ioe) {
    ioe.printStackTrace();
    }finally {
    Iterator<File> itListeFiles = listeFiles.iterator();
    while(itListeFiles.hasNext()) {
    File tempFile = (File)itListeFiles.next();
    tempFile.delete();
    }

    Thank you very much.
       public static void sendWithAttach(String p_sender, String p_receiver, String p_subject,
          String p_comment, int p_nombrePiecesJoints, HashMap<String, byte[]> p_files) {
        Properties props = System.getProperties();
        props.put("mail.smtp.host", Solapcore.getCurrent().getServletConfig().getServletContext().getInitParameter("SMTP"));
        Session session = Session.getDefaultInstance(props, null);
        MimeMessage sender = new MimeMessage(session);
        MimeBodyPart mbp1 = new MimeBodyPart();
        Multipart mp = new MimeMultipart();
        List<File> listeFiles = new ArrayList<File>();
        try {
          //On assigne to, from, subject, body, priority
          sender.setRecipients(javax.mail.Message.RecipientType.TO,
              InternetAddress.parse(p_receiver, false));
          sender.setFrom(new InternetAddress(p_sender));
          sender.setSubject(p_subject);
          mbp1.setText(p_comment);
          //sender.setPriority(0);
          mp.addBodyPart(mbp1);
          //On attache les documents
          for(Map.Entry<String, byte[]> entry : p_files.entrySet()) {
            MimeBodyPart mbp2 = new MimeBodyPart();
            String fileName = entry.getKey();
            byte [] dataFile = entry.getValue();
            File file = new File(fileName);
            FileOutputStream fos = new FileOutputStream(file);
            fos.write(dataFile);
            mbp2.attachFile(file);
            mbp2.setFileName(fileName);
            mp.addBodyPart(mbp2);
            listeFiles.add(file);
          sender.setContent(mp);
          Transport.send(sender);
        }catch(MessagingException mex) {
          mex.printStackTrace();
        }catch(FileNotFoundException fnf) {
          fnf.printStackTrace();
        }catch(IOException ioe) {
          ioe.printStackTrace();
        }finally {
          Iterator<File> itListeFiles = listeFiles.iterator();
          while(itListeFiles.hasNext()) {
            File tempFile = (File)itListeFiles.next();
            tempFile.delete();
        }

  • How to send HTML Format Mail using Java Mail in oracle 9i Forms

    Dear All
    could you please tell me how to send HTML Format Mail using Java Mail in oracle 9i Forms and how to implement the java mail ?
    if it is possible, could you please send me the sample code? please very urgent
    Thanks
    P.Sivaraman

    Hello,
    <p>Here is a Form sample.</p>
    Francois

  • How send attachments to mail using oracle alerts

    Hi All,
    I am working on Oracle Alerts in oracle applications. how to send attachment to mail.
    Thanks in Advance,
    Reddy.
    Edited by: user9540785 on Mar 22, 2009 4:48 AM

    As a workaround, you can kick start a custom workflow in actions rather than sending mail. In that custom workflow you can send attachments as part of the notification to the respective recipients.
    Thanks
    Nagamohan

  • Getting: Unable to send attachment with Mail Drop

    Mail Drop is not working for me, I always get error message while trying to send.
    Here is what happens:
    -I compose a message that includes a large attachment
    -I click send
    -I get the message "Unable to send attachment with Mail Drop" for a few seconds
    -My message is not sent and it goes into the Outbox folder.
    Configuration:
    OS X 10.10 Yosemite
    Mail -> Preferences -> Accounts -> Advanced. The option "Send large attachments with Mail Drop" is selected.

    I had the exact same problem.  I finally figured out what was wrong.  I believe you must have iCloud Drive turned on in System Preferences AND you also must allow mail to store document in iCloud Drive which you can check by clicking the "Options..." button in the preference pane of iCloud Drive. As you can see below.

  • Can you send encrypted e-mails using SO_NEW_DOCUMENT_ATT_SEND_API1

    We use SO_NEW_DOCUMENT_ATT_SEND_API1 to send e-mails to employees for various notifications.  The e-mails go out through SCOT and are sent to our lotus notes.
    We have a project being implemented, where the data we are sending in the note is kind of sensitive, so we'd like to see if we could send the e-mail as encrypted.   Does anyone know if there is some parameter we can set upon sending that would encrypt the text in the e-mail for sending?

    FORM pssword_prot_encryptpdf .
      DATA: BEGIN OF command_list OCCURS 0.
              INCLUDE STRUCTURE sxpgcolist.
      DATA: END OF command_list .
      DATA: BEGIN OF exec_protocol OCCURS 0.
              INCLUDE STRUCTURE btcxpm.
      DATA: END OF exec_protocol.
      DATA: status LIKE btcxp3-exitstat,
      commandname LIKE sxpgcolist-name VALUE 'ZTEST',
      sel_no LIKE sy-tabix.
    * GET LIST OF EXTERNAL COMMANDS
      CALL FUNCTION 'SXPG_COMMAND_LIST_GET'
        EXPORTING
          commandname     = commandname
          operatingsystem = sy-opsys
        TABLES
          command_list    = command_list
        EXCEPTIONS
          OTHERS          = 1.
      CALL FUNCTION 'SXPG_COMMAND_CHECK'
        EXPORTING
          commandname                = command_list-name
          operatingsystem            = sy-opsys
        EXCEPTIONS
          no_permission              = 1
          command_not_found          = 2
          parameters_too_long        = 3
          security_risk              = 4
          wrong_check_call_interface = 5
          x_error                    = 6
          too_many_parameters        = 7
          parameter_expected         = 8
          illegal_command            = 9
          communication_failure      = 10
          system_failure             = 11
          OTHERS                     = 12.
      CLEAR command_list.
      REFRESH command_list.
      DATA: v_dir_input      TYPE sxpgcolist-parameters.
      DATA: v_dir_input1      TYPE sxpgcolist-parameters.
      break developer.
      command_list-name = 'ZTEST'.
      command_list-opsystem = 'Windows NT'.
      CONCATENATE   'd:\pdf\' main_dtl-vbeln '.PDF' INTO name.
      CONCATENATE 'cmd /c d:\pdf\encryptpdf.exe' '-i' name  '-o ' name  '-u'  hdr-password INTO v_dir_input SEPARATED BY space .
      READ TABLE command_list INDEX sel_no.
      break developer.
      CONCATENATE command_list-opcommand v_dir_input INTO command_list-opcommand SEPARATED BY space.
    * CHECK AUTHORIZATION
      command_list-addpar = 'X'.
      APPEND command_list.
      CONSTANTS: c_extcom    TYPE sxpgcolist-name VALUE 'ZTEST',
                 c_oper      TYPE syopsys VALUE 'Windows NT'.
      DATA: t_result         TYPE STANDARD TABLE OF btcxpm.
      v_dir_input  =  command_list-opcommand.
      CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
        EXPORTING
          commandname                   = c_extcom
          additional_parameters         = v_dir_input
          operatingsystem               = c_oper
        TABLES
          exec_protocol                 = t_result
        EXCEPTIONS
          no_permission                 = 1
          command_not_found             = 2
          parameters_too_long           = 3
          security_risk                 = 4
          wrong_check_call_interface    = 5
          program_start_error           = 6
          program_termination_error     = 7
          x_error                       = 8
          parameter_expected            = 9
          too_many_parameters           = 10
          illegal_command               = 11
          wrong_asynchronous_parameters = 12
          cant_enq_tbtco_entry          = 13
          jobcount_generation_error     = 14
          OTHERS                        = 15.
    ENDFORM.                    " PSSWORD_PROT

  • How to send pdf attachment through mail using Webdynpro-Java

    How can i send the Adobe Interactive Form with data involved as a PDF attachment to mail? using Webdynpro-Java.
    Is there any Adobe API or jar file for generating pdf?
    Helpful answer is highly appreciable and rewarded with points.!

    Hi Sankar,
    try [Offline Interactive PDF Form Using E-Mail|/docs/DOC-8061#49]
    Michal

  • Sending Cheque as PDF attachment in Mail using F110.

    Hi all,
    We have a requirement to send the cheque as as PDF attachment in Mail while printing it through transaction F110.Mail has to be triggered when the payment run is done through F110.Is there any config setting to do this without doing any changes to Print program RFFOUS_C.
    Thanks and Regards
    Kiran

    Hi,
    check below link
    https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/email%2bfrom%2bsap 
    Regards,
    Madhu

  • Send multiple email attachments using FM SO_NEW_DOCUMENT_ATT_SEND_API1.How?

    Hi All,
    I have a requirement to send email to an external ID for which I am using FM SO_NEW_DOCUMENT_ATT_SEND_API1.Can anyone give a sample code to send multiple excel attachments using this function module.
    Points would be rewarded.
    Thanks
    Archana.

    Check the Thread,,
    Re: more than 1 attachements/sheets in SO_DOCUMENT_SEND_API1

  • Send a text file using  MF SO_NEW_DOCUMENT_ATT_SEND_API1

    HI.
    I am trying send a file text from a internal table using the MF: SO_NEW_DOCUMENT_ATT_SEND_API1, the code for tranfer the internal table   is:
    LOOP AT i_bultos_inex2.
          mailbin-line(20) = i_bultos_inex2-cod_bulto.
          mailbin-line+20(8) = i_bultos_inex2-fecha.
          mailbin+254(1) = cl_abap_char_utilities=>cr_lf.
          APPEND mailbin.CLEAR mailbin.
        ENDLOOP.
    In the file send by e-mail, the lines are not adjusted to the left and each line of the internal table not is a line in the file text.
    How i can solved?
    Thanks.

    Hi,
    Try to use
        call function 'SCMS_STRING_TO_FTEXT'
          exporting
            text      = string
          tables
            ftext_tab = mailbin.
    I think you are not working unicode system

  • Mail won't send attached e-mail.

    Greetings,
    I'm a new Mac user, and I'm having this problem with my mail account. When I try to send an e-mail that has attachments to it, it takes a long time to send (that is, if it sends). The little blue bar that says "Outgoing messages" is completely full, and it does not send. And it doesn't matter the size of the e-mail nor the size of the attachment, it still does not send.
    Please help.
    Att.

    I don't use Hotmail (I'm allergic to any Microsoft product ), but I'd check both your ISP's and Hotmail's maximum allowed email/attachments file size. I have a Yahoo account and they do have not only a maximum on the number of attachments, but also the file size. Are you sending it to a large number of recipients? That could be another problem - some ISP's limit the number of recipients to discourage spammers.

  • How to stop the sending attachment through mail group policy

    HI ,.,,,
           Our employees using the gmail and yahoo accounts sometimes . Due to security issues they dont send attachements how is possible to deny sending attachments in group policy
    ranki

    Hi,
    How do your employees using their personal mailbox? If they access it via Outlook, please refer to the suggestions Maffiow provided. If they access it via IE, we could not prevent them attaching
    file to their mailbox via Group Policy. As a workaround, you may prevent them accessing the third party mailbox webpage via Group Policy.
    For details, please refer to the following article.
    How to use Group Policy to Allow or Block URL’s
    http://www.grouppolicy.biz/2010/07/how-to-use-group-policy-to-allow-or-block-urls/
    Hope this helps.
    Best Regards,
    Andy Qi
    TechNet Subscriber Support
    If you are
    TechNet Subscription user and have any feedback on our support quality, please send your feedback
    here.
    Andy Qi
    TechNet Community Support

  • Sateillite A200-1A9: Issue with sending/receiving E-mail using Windows Mail

    Using Windows mail I have to close/open the programme to be able to send mails, they get stuck in the Outbox. By closing and reopening the programme the mail gets sent. Also the Blue figure 1 in brackets showning 1 unread mail in the Outbox is there all the time although there is no mails read or unread in the Outbox
    Not a server problem as all mails are going/receiving fine on my desktop.
    Pressing send and receive button does not help. although some of the time it will receive mails when pressing send/receive but will not send them
    I do have Norton Internet security 2007 and am getting fed up with the continuing problems that this seems to cause over the period 2004-7.
    Is there an issue with the Windows mail programme running with Vista that is known

    I think I have found a solution
    Please check this:
    Windows Mail will not Send or Receive mails
    http://support.toshiba-tro.de/kb0/TSB7701X30005R01.htm
    It seems that the update of Software Desktop SMS to the newest version will help to sort out this problem.

Maybe you are looking for

  • Error when message mapping refers to old SWCV

    When you open a message mapping that has a message type from an old SWCV, e.g. FSAPPL 200, but this Enterprise Service Repository only has a newer version of the SWCV, e.g. FSAPPL 400, you get an error and you cannot display the mapping. Is there a w

  • Need some help in QR Code generation process

    Hi All, Actually I placed this query before. But I have not got usefull messages. But When I go through the below link I got hopes that I can crack this QR Code requirment but https://www.sounderp.com/index.php/howto/38-faq/53-2dmatrixbarcodes I need

  • Error in b2b shop url.

    Hi all I am new to sap crm ,i am woring  on E-COMMERCE  when i try to log on  into b2b shop by using   url:http://saperp.sap.com:50000/b2b/b2b/init.do  system seeking  the following error "ISA Frame work: com.sap.engineservice.servlet_jsp.server,exce

  • Firefox SYNC 1.4.4 website error or ??

    HI, I am running Firefox 3.6.8 on a Win 7 machine and just added Firefox Sync to it. I also have a Vista machine running Firefox 3.6.8 BUT when I try to install SYNC the website says I am running 3.0.14 and will not load SYNC 1.4.4. Why is the websit

  • Options and settings

    I just received this thing last night. Setup everything, works fine except for the usb hard drive, that'll apparently take some more work from what i've read. I have a couple of questions though.. 1. I can't see anywhere to disable the ping on the wa