Sending mail from plsql with attachement

Hi Friends,
i wanted to prepare an excel report and send that by email useing PLSQL .
i know the inbuild packages UTL_FILE and UTL_SMTP can do this job . But my DBA not allowing me to do this . My DBA adviced me to do this work with in database by inplementing BLOB.
I have never come accross to this task with in database , ( preparing the excel file and attaching that with mail and send it to users ) ??.
can some one share tips & sample codes if any ???
Thank You,
Raj.

First thing is Excel is Microsoft Specific and cant be created using UTL_FILE. May be as Excel supports CSV you can create CSV file using UTL_FILE.
Next BLOB is a datatype like CHAR or VARCHAR2. You can store data in it. Thats all nothing much. With BLOB you can store an excel file. BLOB can't create or send it via EMail.
So it would be better you talk to your DBA asking him to give more details.
Thanks,
Karthick.

Similar Messages

  • Problem in sending mail from database with attachment

    Hi All,
    I amd using forms10g,oracle10g
    I am facing a error while running a procedure to send mail from db
    procedure is:
    declare
    ErrorMessage VARCHAR2(4000);
    ErrorStatus NUMBER;
    -- enable SQL*PLUS output;
    --SET SERVEROUTPUT ON
    -- redirect java output into SQL*PLUS buffer;
    --exec dbms_java.set_output(5000);
    BEGIN
    ErrorStatus := SendMailJPkg.SendMail(
    SMTPServerName => '192.168.4.2',
    Sender => '[email protected]',
    Recipient => '[email protected]',
    CcRecipient => '',
    BccRecipient => '',
    Subject => 'hth106: Test JavaMail',
    Body => 'This is the body: Hello, this is a test that spans 2 lines',
    AuthReqdYNNum => 1,
    UserID => 'jagan',
    Password => 'songbirds',
    ErrorMessage => ErrorMessage,
    Attachments => SendMailJPkg.ATTACHMENTS_LIST('C:\oramail\MHTHSO_GEN45.html')
    END;
    while running this procedure i am receiving following error
    "ORA-29532: Java call terminated by uncaught Java exception:
    java.lang.IncompatibleClassChangeError"
    but the same procedure sending mail from all other user in the same database
    I am very myuch confused.i have given the all rights
    below mentioned rights are given .it is working in all other user on the same db except this user "hth106". And all the othere things are compared between working user and this hth106 user every things are same.But i am receiving error when i sending mail with attachment if the mail is sending without attachement it is working fine
    below rights are given to this user
    1.exec dbms_java.grant_permission('HTH106','java.util.PropertyPermission','*','read');
    2.exec dbms_java.grant_permission('HTH106','java.util.PropertyPermission','*','write');
    3.exec dbms_java.grant_permission('HTH106','java.net.SocketPermission','*','connect');
    4.exec dbms_java.grant_permission('HTH106','java.net.SocketPermission','*','resolve');
    5.exec dbms_java.grant_permission('HTH106','java.io.FilePermission','C:\oramail\*','read');
    exec dbms_java.grant_permission('HTH106','java.io.FilePermission','C:\oramail\*','write');
    6.call dbms_java.grant_permission('HTH106','java.net.SocketPermission','HTHDS01','resolve');
    7.call dbms_java.grant_permission('HTH106','java.util.PropertyPermission','*','read,write');
    7.call dbms_java.grant_permission('HTH106', 'java.io.FilePermission','C:\oramail\*','read');
    please advise me to proceed further
    Thanks in advance
    Thanks ,
    Antony

    With respects to the following:
    The bit you'll have most diffulty with is the attachment, because you can't be sure that
    the directory path specified is one that the database can read from. You can probably
    resolve this by using some java to move the file to a directory which utl_file can see.Another alternative is to specify a location on then database server where all file attachments MUST be copied to and the define and Oracle DIRECTORY (CREATE OR REPLACE DIRECTORY [dir_name] AS '/dir/name/on/files/system';) that references this location. When you attach a file to an email, then you only have to refer to the DIRECTORY for the file location.
    Just my 2 cents on the topic. :-)
    Craig...

  • Sending mail from servers with non-ASCII names

    As part of an effort to internationalize our product we're testing on machines with host names that include non-ASCII characters (accented e's and whatnot). When trying to send mail from these machines we're getting:
    javax.mail.MessagingException: 501 5.5.4 Invalid Address
    at com.sun.mail.smtp.SMTPTransport.issueCommand(SMTPTransport.java:1634)
    at com.sun.mail.smtp.SMTPTransport.helo(SMTPTransport.java:1068)
    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:458)
    at javax.mail.Service.connect(Service.java:291)
    at javax.mail.Service.connect(Service.java:172)
    at javax.mail.Service.connect(Service.java:121)
    at javax.mail.Transport.send0(Transport.java:190)
    at javax.mail.Transport.send(Transport.java:120)
    at msgsendsample.main(msgsendsample.java:86)
    Looking at a network trace I see the EHLO command being sent as
    EHLO test[0xe9][0xdf]\r\n
    where the machine name is testéß. From a Unicode table 0xe9 0xdf = é ß.
    I found a reference from RFC 5336 (SMTP Extension for Internationalized Email Addresses) that says the hostname in the EHLO must be in the form of ACE (ASCII-compatible encoding) labels:
    3.7.1. The Initial SMTP Exchange
    When an SMTP connection is opened, the server normally sends a
    "greeting" response consisting of the 220 response code and some
    information. The client then sends the EHLO command. Since the
    client cannot know whether the server supports UTF8SMTP until after
    it receives the response from EHLO, any domain names that appear in
    this dialogue, or in responses to EHLO, MUST be in the hostname form,
    i.e., internationalized ones MUST be in the form of ACE labels.
    ACE encoding for my machine would be: java.net.IDN.toASCII("test4éß") --> "xn--testss-eva".
    I'm not sure if this RFC applies in this case - I didn't know anything about the guts of SMTP until yesterday - but it makes sense that you'd need to escape the hostname in the EHLO until you can negotiate capabilities.
    Looking at the JavaMail API it seems that if I were to call SMTPTransport.helo(String domain) myself without going through the higher-level Transport class that maybe I could work around the issue, but I haven't looked into it enough to know if that's feasible.
    Is anyone familiar with this problem? I'm using JavaMail 1.4.2 on Windows 2003 and Exchange as my SMTP server.
    thanks,
    Eric

    Same problem here (or at least in part). Some .mac folders did no longer show any messages, while they were there and could be seen online and with Thunderbird. After your remark I changed the name of a folder which contained a "´" and now it works. It is really strange because there is another folder with a "¨" in it which does not work (I will test if the name change works with this folder as well in a minute) whilst there is another one with such name which works fine. The update really messed up Mail and in Dutch we just use such characters so Mail without supporting them will be rather useless for me...

  • How to send mail from linux with .txt file as attachment ..

    I want to send email from linux box and in the body of the email i want to have the content of dblog.txt file.
    I want dglob.txt file content to be part of the mail body.
    Thanks in advance!!

    Apr 29 15:19:35 lctwprddb01 sendmail[1616]: m3TJJZ4k001616: to=[email protected], ctladdr=oracle (500/500), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30109, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (m3TJJZhB001617 Message accepted for delivery)
    Apr 29 16:04:52 lctwprddb01 sendmail[1422]: m3TIP6LJ031388: to=<[email protected]>, ctladdr=<[email protected]> (500/500), delay=01:39:46, xdelay=00:48:01, mailer=esmtp, pri=120423, relay=cluster2a.us.messagelabs.com. [216.82.249.211], dsn=4.0.0, stat=Deferred: Connection timed out with cluster2a.us.messagelabs.com.
    Apr 29 16:07:36 lctwprddb01 sendmail[1619]: m3TJJZhB001617: to=<[email protected]>, ctladdr=<[email protected]> (500/500), delay=00:48:01, xdelay=00:48:01, mailer=esmtp, pri=120425, relay=cluster2a.us.messagelabs.com. [216.82.248.44], dsn=4.0.0, stat=Deferred: Connection timed out with cluster2a.us.messagelabs.com.
    Apr 29 16:07:52 lctwprddb01 sendmail[1627]: m3TILs2r031176: to=<[email protected]>, ctladdr=<[email protected]> (500/500), delay=01:45:58, xdelay=00:48:01, mailer=esmtp, pri=120429, relay=cluster2a.us.messagelabs.com. [216.82.248.45], dsn=4.0.0, stat=Deferred: Connection timed out with cluster2a.us.messagelabs.com.

  • Sender Mail adapter configuration with attachment

    Hi,
    I read the below blog regarding the mail adapter
    /people/michal.krawczyk2/blog/2005/12/18/xi-sender-mail-adapter--payloadswapbean--step-by-step
    I have the same requirement but the attachment file is not an XML, it is CSV file so in the module tab if I change like below is it enough?
    TRANSFORM    swap.keyValue  attachment; filename=u201DMailAttachment-1.csvu201D     (I think MailAttachment-1 is the file name, am I correct?)
    If I change like above is it ok? or any other thing is required, Could you please give me the inputs
    Thanks
    Ramesh

    I have the same requirement but the attachment file is not an XML, it is CSV file so in the module tab if I change like below is
    it enough?
    PayloadSwapBean will ensure that the input to the mapping is from the attachment.....in the blog the attachment is in XML format and hence there was no need for any conversion.....yours is however a CSV file so you need to convert it to XML first and then do the further processing.....you can either use the MessageTransformationBean as shown in this blog:
    /people/gabrielsagayaselvam.panneerselvam/blog/2009/08/31/solve-key-field-problem-using-structplain2xml-in-messagetransformationbean
    Or write your own module code for the conversion.
    Regards,
    Abhishek.

  • Email from Plsql with attachment

    Hello Masters,
    I have a requirement where system needs to send the email with attachment. In my case I already have a file which needs to be send as attachment and stored in a directory (on database server).
    Directory is created using below commands;
    CREATE OR REPLACE DIRECTORY TEST_DIR AS 'c:\myfiles';
    GRANT READ, WRITE ON DIRECTORY TEST_DIR TO USER_SCHEMA;
    I just want to send mail with that file as attachment, basically there should be something where I should specify the path and it gets attached to the email.
    Hope I have made clear. Kindly help me out for same.
    Regards,

    Thanks FrankKulash/Hoek,
    I tried UTL_MAIL package, but couldn't get through. Below is what I tried;
    DECLARE
      V_DIR    VARCHAR2 (30) := 'TEST_DIR';
      V_FILE  VARCHAR2 (30) := 'myfile1.xlsx';
    BEGIN
      SYS.UTL_MAIL.SEND_ATTACH_RAW (
          SENDER          => '[email protected]',
          RECIPIENTS      => '[email protected]',
          MESSAGE        => '<HTML><BODY>See attachment</BODY></HTML>',
          SUBJECT        => 'Oracle Notes',
          MIME_TYPE      => 'text/html',
          ATTACHMENT      => V_DIR || '\' || V_FILE,
          ATT_INLINE      => FALSE,
          ATT_MIME_TYPE  => 'text/plain',
          ATT_FILENAME    => V_FILE);
    END;
    After executing above, I get error like;
    ORA-06502: PL/SQL: numeric or value error: hex to raw conversion error
    ORA-06512: at line 5

  • Send Mail from workflow with a Long URL

    Hello,
    My problem is that when an email gets generated from the workflow in my application, the generated url is quite long. As a result the link is not completely underlined in the email. I know there are limitations discussed in SAP note 363986. But does anybody know a workaround using aliases for the URL? and an example for the same would be great.
    Regards,
    Manoj.
    Message was edited by:
            Manoj Vudathala

    Hello!
    I had the same requirements a while ago and even sent OSS note because customer insisted - even though I informed about the known restrictions.
    Well, SAP replied back that the restrictions are still valid and we tried to use alias and splitting email to multiple container elements but still did not work!
    Using send mail step will simply not work with long URL's!
    But there is a work around if the requirement is business critical - you can create a smartform that has the email text and then pass the URL to the smartform. Smartforms can handle the long URL. You can then trigger a method in your workflow that will send the smartform as email. Hope that gives you an idea!
    Harald

  • Send mail from report with DESNAME and DESFORMAT

    j have tried to send a mail from a report to "outlook express" passing as parameters the email of the user to send the mail.
    i have passed as parameter list :
    DESCNAME = [email protected]
    DESFORMAT = mail
    but aoutlook express don't start.
    It start only if i press the icon "mail" on report, and don't put the email adress in the "send to" field....
    There is a reason or there is an error or it is impossible ????
    Than'k from "il vampiro italiano"

    Hello Mike,
    In order to mail a report from Reports Builder 6i using the system's default MAPI client, you would need to set DESTYPE=MAIL, DESNAME=<email address of recipient> and DESFORMAT=<format of report output>.
    Thanks,
    The Oracle Reports Team.

  • Sending mail from iPhoto with signatures

    I spent a lot of time setting up my signatures which include small jpg's.
    When I send my photos via iPhoto, the jpg's are dropped and it says "unknown" in place of the image I want.
    How can I correct this so that my jpg's are included in my mail via iPhoto?

    First thing is Excel is Microsoft Specific and cant be created using UTL_FILE. May be as Excel supports CSV you can create CSV file using UTL_FILE.
    Next BLOB is a datatype like CHAR or VARCHAR2. You can store data in it. Thats all nothing much. With BLOB you can store an excel file. BLOB can't create or send it via EMail.
    So it would be better you talk to your DBA asking him to give more details.
    Thanks,
    Karthick.

  • Changing Sender Details in Sending mails from SAP

    Hi All,
           I am getting request from legacy system to send mail from along with document. So i am creating the document and attaching   that to send request then the system automatically taking the user login eamil ID as sender Email ID.But My requirement is i have to change the sender email ID as the what ever the email ID i got from legacy system.
    In this i am using class :: CL_SAPUSER_BCS
    Please help me if any implemented this earlier.
    Thanks
    Anil d

    I am using object oriented approach and this is my modified code
    Intially SAP using the following code
        Sender details; Usually user name
         WA_SENDER0 = CL_SAPUSER_BCS=>CREATE( SY-UNAME ).
         call method WA_SENDREQ->SET_SENDER
           exporting
             I_SENDER = WA_SENDER0.
    but i hv commented this one and added my code.then also i can't able to send mails from this class.
    V_SENDER = 'abc.yahoo.com'.
    data: SENDER type ref to CL_CAM_ADDRESS_BCS.
    SENDER = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( V_SENDER ).
    call method WA_SENDREQ->SET_SENDER
    exporting
    I_SENDER = SENDER.
    Thanks

  • How to send mails from Oracle database

    Hi All,
    I want to send a mail from my oracle database once my store
    procedure runs successfully or fails.
    How can i do this.
    what are the preliminary modules of Oracle which need to be
    active for me to do so.
    If any once can also mention about any links that give
    information about the same it will be very helpful for me.
    Thanks and Regards
    Srinivas Chebolu

    CREATE OR REPLACE PROCEDURE SEND_MAIL_TCP(
    msg_from varchar2 := '[email protected]',
    msg_to varchar2,
    msg_subject varchar2 := 'E-Mail message from your database',
    msg_text varchar2 := '' )
    IS
    c utl_tcp.connection;
    rc integer;
    BEGIN
    c := utl_tcp.open_connection('1.17.0.218', 25); -- open the SMTP
    port 25 on local machine
    dbms_output.put_line(utl_tcp.get_line(c, TRUE));
    rc := utl_tcp.write_line(c, 'HELO localhost');
    dbms_output.put_line(utl_tcp.get_line(c, TRUE));
    rc := utl_tcp.write_line(c, 'MAIL FROM: '||msg_from);
    dbms_output.put_line(utl_tcp.get_line(c, TRUE));
    rc := utl_tcp.write_line(c, 'RCPT TO: '||msg_to);
    dbms_output.put_line(utl_tcp.get_line(c, TRUE));
    rc := utl_tcp.write_line(c, 'DATA'); -- Start message body
    dbms_output.put_line(utl_tcp.get_line(c, TRUE));
    rc := utl_tcp.write_line(c, 'Subject: '||msg_subject);
    rc := utl_tcp.write_line(c, '');
    rc := utl_tcp.write_line(c, msg_text);
    rc := utl_tcp.write_line(c, '.'); -- End of message body
    dbms_output.put_line(utl_tcp.get_line(c, TRUE));
    rc := utl_tcp.write_line(c, 'QUIT');
    dbms_output.put_line(utl_tcp.get_line(c, TRUE));
    utl_tcp.close_connection(c); -- Close the connection
    EXCEPTION
    when others then
    raise_application_error(-20000,'Unable to send e-mail message
    from pl/sql');
    END;
    show errors
    exec send_mail(msg_to =>'[email protected]');
    exec send_mail(msg_to
    =>[email protected]',msg_text=>'Look Yaar, I can send
    mail from plsql');

  • "Send an E-Mail in Background with Attachment (Optional)" can't  be called

    hi
    i tried notice from gp's mail template via other object.
    it's successed.
    but when i tried CO "Send an E-Mail in Background with Attachment (Optional)", and code like follows:
              IGPStructure params = GPStructureFactory.getStructure(process.getInputParameters());
              params.setAttributeValue("email_address", receiverMailAddress);
              params.setAttributeValue("customer_Name", receiverName);
              params.setAttributeValue("context", context);
              if (document != null) {
                   IGPStructure attachment = params.addStructure("ATTACHMENT_1", "com.sap.caf.eu.gp.types.File");
                   attachment.setAttributeValue("Name", "com.sap.caf.eu.gp.types.File", documentName);
                   attachment.setAttributeValue("ContentType", "com.sap.caf.eu.gp.types.File", documentContentType);
                   attachment.setAttributeValue("Size", "com.sap.caf.eu.gp.types.File", document.length);
                   attachment.setAttributeValue("Content", "com.sap.caf.eu.gp.types.File", document);
    it ain't work.
    also, did not throw any exception.
    i found some exception message from log viewer
    null
    com.sap.caf.eu.gp.base.exception.EngineException
    at com.sap.caf.eu.gp.model.fnd.mail.MailSendingUtility.sendMailThrowsExc(MailSendingUtility.java:889)
    at com.sap.caf.eu.gp.model.fnd.mail.MailSendingUtility.sendMailThrowsExc(MailSendingUtility.java:837)
    at com.sap.caf.eu.gp.callobj.mail.NotificationCOwithAttachment.onExecute(NotificationCOwithAttachment.java:394)
    at com.sap.caf.eu.gp.callobj.bckgd.base.AbstractBackgroundCallableObject.execute(AbstractBackgroundCallableObject.java:102)
    at com.sap.caf.eu.gp.callobj.container.BackgroundCallableObjectsContainer.execute(BackgroundCallableObjectsContainer.java:82)
    i work with netweaver 7.11 ehp1 sp3.
    please help if you can, thank you very much.

    Hi, Dipankar:
    Thanks for your reply. But I have no idea about how to group parameter from all uploaded file to "Send an E-Mail in Background with Attachment" CO?
    For the situation, I write a background CO program to get all uploaded file (from first three block) and grouping this customized CO parameter with "Send an E-Mail in Background with Attachment" CO.

  • Add many attachment to CO "Send an E-Mail in Background with Attachment"

    Hi, experts:
    I create a guided procedure which contain 4 sequential block.
    in first 3 block, every user will upload their own file.
    In the last block, I want collect all uploaded file, and pass to CO "Send an E-Mail in Background with Attachment" to mail to the user who assign to the fourth block.
    Any idea about what block type I should use in fourth block?
    Thanks in advance.

    Hi, Dipankar:
    Thanks for your reply. But I have no idea about how to group parameter from all uploaded file to "Send an E-Mail in Background with Attachment" CO?
    For the situation, I write a background CO program to get all uploaded file (from first three block) and grouping this customized CO parameter with "Send an E-Mail in Background with Attachment" CO.

  • Cant send mail from i phone 3s, with a tiscali account

    I can no longer send mail from my tiscali mail account on my i phone 3s, or my ipad without going through web mail account. please can anyone advise

    Isn't mail.virgin.net the name of the Incoming Server -- the incoming server, which you say is working is set up at Mail Preferences/Accounts/Account Information as to name of the server, Username, and password, along with entries in Mail Preferences/Accounts/Advanced for Port select for the Incoming.
    However, if that is working for you, you must have it correct. For the Outgoing server, isn't the proper name for Virgin services smtp.virgin.net? In Mail Preferences/Accounts/Account Information, click on the arrows beside the name of the SMTP, and choose Edit Server List. Remove all, or all but one of any references to the smtp.virgin.net. Enter anew, or with the remaining server, click on the Advanced Tab there, and choose Use Custom Ports. Then enter the Custom Port to be Port 25, and set the Authentication to None, and have no entries in Username or Password. This is consistent with those specs I can online saying the SMTP does not require Authentication.
    Also click Use this server only. Now if the smtp.virgin.net server is online, it should work.
    Ernie

  • Function module to send mail from SAP

    Can any one please tell the Function module to send mail from SAP. The scenario is like this,I have a file in local system that i have to send to a particular mail address like [email protected] through a report program.

    Hi shafiq,
    1. There is some trick involved
    in the binary files.
    2. I have made a program (and it works fantastic)
    ONLY 6 LINES FOR EMAILING
    BELIEVE ME
    ITS A FANTASTIC PROGRAM.
    IT WILL WORK LIKE OUTLOOK EXPRESS !
    3. The user is provided with
    a) file name
    b) email address to send mail
    and it sends ANY FILE (.xls,.pdf .xyz..)
    Instantaneously !
    4. Make two things first :
    1. Include with the name : ZAMI_INCLFOR_MAIL
    2. Report with the name : ZAM_TEMP147 (any name will do)
    3. Activate both and execute (2)
    4. After providing filename, email adress
    5. Code for Include :
    10.08.2005 Amit M - Created
    Include For Mail (First Req F16)
    Modification Log
    Data
    DATA: docdata LIKE sodocchgi1,
    objpack LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE,
    objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
    objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
    objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE,
    objhex LIKE solix OCCURS 10 WITH HEADER LINE,
    reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE.
    DATA: tab_lines TYPE i,
    doc_size TYPE i,
    att_type LIKE soodk-objtp.
    DATA: listobject LIKE abaplist OCCURS 1 WITH HEADER LINE.
    FORM
    FORM ml_customize USING objname objdesc.
    Clear Variables
    CLEAR docdata.
    REFRESH objpack.
    CLEAR objpack.
    REFRESH objhead.
    REFRESH objtxt.
    CLEAR objtxt.
    REFRESH objbin.
    CLEAR objbin.
    REFRESH objhex.
    CLEAR objhex.
    REFRESH reclist.
    CLEAR reclist.
    REFRESH listobject.
    CLEAR listobject.
    CLEAR tab_lines.
    CLEAR doc_size.
    CLEAR att_type.
    Set Variables
    docdata-obj_name = objname.
    docdata-obj_descr = objdesc.
    ENDFORM. "ml_customize
    FORM
    FORM ml_addrecp USING preceiver prec_type.
    CLEAR reclist.
    reclist-receiver = preceiver.
    reclist-rec_type = prec_type.
    APPEND reclist.
    ENDFORM. "ml_customize
    FORM
    FORM ml_addtxt USING ptxt.
    CLEAR objtxt.
    objtxt = ptxt.
    APPEND objtxt.
    ENDFORM. "ml_customize
    FORM
    FORM ml_prepare USING bypassmemory whatatt_type whatname.
    IF bypassmemory = ''.
    Fetch List From Memory
    CALL FUNCTION 'LIST_FROM_MEMORY'
    TABLES
    listobject = listobject
    EXCEPTIONS
    OTHERS = 1.
    IF sy-subrc <> 0.
    MESSAGE ID '61' TYPE 'E' NUMBER '731'
    WITH 'LIST_FROM_MEMORY'.
    ENDIF.
    CALL FUNCTION 'TABLE_COMPRESS'
    IMPORTING
    COMPRESSED_SIZE =
    TABLES
    in = listobject
    out = objbin
    EXCEPTIONS
    OTHERS = 1
    IF sy-subrc <> 0.
    MESSAGE ID '61' TYPE 'E' NUMBER '731'
    WITH 'TABLE_COMPRESS'.
    ENDIF.
    ENDIF.
    Header Data
    Already Done Thru FM
    Main Text
    Already Done Thru FM
    Packing Info For Text Data
    DESCRIBE TABLE objtxt LINES tab_lines.
    READ TABLE objtxt INDEX tab_lines.
    docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
    CLEAR objpack-transf_bin.
    objpack-head_start = 1.
    objpack-head_num = 0.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
    objpack-doc_type = 'TXT'.
    APPEND objpack.
    Packing Info Attachment
    att_type = whatatt_type..
    DESCRIBE TABLE objbin LINES tab_lines.
    READ TABLE objbin INDEX tab_lines.
    objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).
    objpack-transf_bin = 'X'.
    objpack-head_start = 1.
    objpack-head_num = 0.
    objpack-body_start = 1.
    objpack-body_num = tab_lines.
    objpack-doc_type = att_type.
    objpack-obj_name = 'ATTACHMENT'.
    objpack-obj_descr = whatname.
    APPEND objpack.
    Receiver List
    Already done thru fm
    ENDFORM. "ml_prepare
    FORM
    FORM ml_dosend.
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
    document_data = docdata
    put_in_outbox = 'X'
    commit_work = 'X' "used from rel. 6.10
    IMPORTING
    SENT_TO_ALL =
    NEW_OBJECT_ID =
    TABLES
    packing_list = objpack
    object_header = objhead
    contents_bin = objbin
    contents_txt = objtxt
    CONTENTS_HEX = objhex
    OBJECT_PARA =
    object_parb =
    receivers = reclist
    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 'SO' TYPE 'S' NUMBER '023'
    WITH docdata-obj_name.
    ENDIF.
    ENDFORM. "ml_customize
    FORM
    FORM ml_spooltopdf USING whatspoolid.
    DATA : pdf LIKE tline OCCURS 0 WITH HEADER LINE.
    Call Function
    CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
    EXPORTING
    src_spoolid = whatspoolid
    TABLES
    pdf = pdf
    EXCEPTIONS
    err_no_otf_spooljob = 1
    OTHERS = 12.
    Convert
    PERFORM doconv TABLES pdf objbin.
    ENDFORM. "ml_spooltopdf
    FORM
    FORM doconv TABLES
    mypdf STRUCTURE tline
    outbin STRUCTURE solisti1.
    Data
    DATA : pos TYPE i.
    DATA : len TYPE i.
    Loop And Put Data
    LOOP AT mypdf.
    pos = 255 - len.
    IF pos > 134. "length of pdf_table
    pos = 134.
    ENDIF.
    outbin+len = mypdf(pos).
    len = len + pos.
    IF len = 255. "length of out (contents_bin)
    APPEND outbin.
    CLEAR: outbin, len.
    IF pos < 134.
    outbin = mypdf+pos.
    len = 134 - pos.
    ENDIF.
    ENDIF.
    ENDLOOP.
    IF len > 0.
    APPEND outbin.
    ENDIF.
    ENDFORM. "doconv
    CODE FOR PROGRAM
    5.
    REPORT zam_temp147 .
    INCLUDE zami_inclfor_mail.
    DATA
    DATA : itab LIKE tline OCCURS 0 WITH HEADER LINE.
    DATA : file_name TYPE string.
    data : path like PCFILE-PATH.
    data : extension(5) type c.
    data : name(100) type c.
    SELECTION SCREEN
    PARAMETERS : receiver TYPE somlreci1-receiver lower case.
    PARAMETERS : p_file LIKE rlgrap-filename
    OBLIGATORY.
    AT SELECTION SCREEN
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    CLEAR p_file.
    CALL FUNCTION 'F4_FILENAME'
    IMPORTING
    file_name = p_file.
    START-OF-SELECTION
    START-OF-SELECTION.
    PERFORM ml_customize USING 'Tst' 'Testing'.
    PERFORM ml_addrecp USING receiver 'U'.
    PERFORM upl.
    PERFORM doconv TABLES itab objbin.
    PERFORM ml_prepare USING 'X' extension name.
    PERFORM ml_dosend.
    SUBMIT rsconn01
    WITH mode EQ 'INT'
    AND RETURN.
    FORM
    FORM upl.
    file_name = p_file.
    CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename = file_name
    filetype = 'BIN'
    TABLES
    data_tab = itab
    EXCEPTIONS
    file_open_error = 1
    file_read_error = 2
    no_batch = 3
    gui_refuse_filetransfer = 4
    invalid_type = 5
    no_authority = 6
    unknown_error = 7
    bad_data_format = 8
    header_not_allowed = 9
    separator_not_allowed = 10
    header_too_long = 11
    unknown_dp_error = 12
    access_denied = 13
    dp_out_of_memory = 14
    disk_full = 15
    dp_timeout = 16
    OTHERS = 17.
    path = file_name.
    CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
    EXPORTING
    complete_filename = path
    CHECK_DOS_FORMAT =
    IMPORTING
    DRIVE =
    EXTENSION = extension
    NAME = name
    NAME_WITH_EXT =
    PATH =
    EXCEPTIONS
    INVALID_DRIVE = 1
    INVALID_EXTENSION = 2
    INVALID_NAME = 3
    INVALID_PATH = 4
    OTHERS = 5
    ENDFORM. "upl
    regards,
    amit m.

Maybe you are looking for