Error in sending mail Using java application using SMTP.

Hi,
I have created a java application of self user registration which also sends email to the user.
I have also added two JAR files ie mail.jar and activation.jar under the PORTAL_INF/lib.
The code works well in other servers but its showing the error-
java.lang.NoSuchMethodError: com.sun.activation.registries.MailcapFile.getMailcapList(Ljava/lang/String;)Ljava/util/Map;
Thanks & Regards,
Amarys.

Hi Amarys,
Please check if you have configure the mail server in SAP protal.
Refer to below documents:
[Send email, using SMTP on remote host|Send email, using SMTP on remote host]
[Mailing throw webdynpro for java|Mailing throw webdynpro for java]
Best Regards
Arun Jaiswal

Similar Messages

  • Send mail from Portal application using java

    Hi everybody,
    I'm looking for a way to send mails from my portal application written in java.
    Now I've read a lot of topics on this but can't seem to get it straight.
    I added a few jars to my project among which is
    coll.appl.gw.srvcmail_api.jar
    Here you have the ISendMailItem.class and ISendMailService.class files.
    Now I know these are interfaces so I created 2 new classes:
    Mail implementing ISendMailItem
    SendMail implementing ISendMailService
    And all of the forced methods are created for me but now I don't know how to use these classes to be able to send a mail.
    Can someone help me with this please?
    Thank you
    Regards
    Wouter

    Hey Göran,
    Thank you for this example.
    for the transport i've put this
    transport.connect( "smtpgateway.arinso.com", "", "" );
    Is this correct? or do I need to fill in more info?
    I've adde the mail.jar to my buildpath and put your code in a eventhandler.
    When I now generate the corresponding event i get an Exception:
    java.lang.ClassCastException: javax.mail.Session
    Do you know why I get this?
    Thank you
    Wouter
    Message was edited by:
            Wouter Delellio

  • UnsupportedDataTypeException when sending mail from Java application

    I try to get the Java Mail API running. I'm able to compile all sample programs delivered with the API but when I try to run e.g. msgsend, msgsendsample or a sample that I found in this discussion (zmail from zakir_sh), I always get the same error:
    javax.mail.SendFailedException: Sending failed;
    nested exception is:
    javax.mail.MessagingException: IOException while
    sending message;
    nested exception is:
    javax.activation.UnsupportedDataTypeException: no
    object DCH for MIME type text/plain; charset=us-ascii
    Does anybody has the same problem? What's going wrong?

    Initially, I too had difficulty with JavaMail, mainly because I did not read the documentation carefully enough.
    I bypassed msgsend, etc. and wrote a very basic program to send mail; fired up my dial-up-connection and everything worked beautifully.
    Try the same. If you don't succeed, post your code here.
    Good luck.

  • Error in sending mail using ssl server

    Hi All
    Please help in resolving the below issue i am getting the following error while sending mail. I am using the IMAP server and it is ssl configured.
    DEBUG: setDebug: JavaMail version 1.4ea
    DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc]
    DEBUG SMTP: useEhlo true, useAuth false
    DEBUG SMTP: trying to connect to host "mail.test.com", port 465, isSSL true
    DEBUG SMTP: exception reading response: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: subject/issuer name chaining check failed
    javax.mail.MessagingException: Exception reading response;
      nested exception is:
         javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: subject/issuer name chaining check failed
         at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1462)
         at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1260)
         at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:370)
         at javax.mail.Service.connect(Service.java:275)
         at com.test.test.JavaMailApp2.main(JavaMailApp2.java:59)
    Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: subject/issuer name chaining check failed
         at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Unknown Source)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(Unknown Source)
         at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Unknown Source)
         at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Unknown Source)
         at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(Unknown Source)
         at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(Unknown Source)
         at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Unknown Source)
         at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Unknown Source)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown Source)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
         at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readDataRecord(Unknown Source)
         at com.sun.net.ssl.internal.ssl.AppInputStream.read(Unknown Source)
         at com.sun.mail.util.TraceInputStream.read(TraceInputStream.java:97)
         at java.io.BufferedInputStream.fill(Unknown Source)
         at java.io.BufferedInputStream.read(Unknown Source)
         at com.sun.mail.util.LineInputStream.readLine(LineInputStream.java:75)
         at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1440)
         ... 4 more
    Caused by: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: subject/issuer name chaining check failed
         at sun.security.validator.PKIXValidator.doValidate(Unknown Source)
         at sun.security.validator.PKIXValidator.doValidate(Unknown Source)
         at sun.security.validator.PKIXValidator.engineValidate(Unknown Source)
         at sun.security.validator.Validator.validate(Unknown Source)
         at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.validate(Unknown Source)
         at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)
         at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(Unknown Source)
         ... 17 more
    Caused by: java.security.cert.CertPathValidatorException: subject/issuer name chaining check failed
         at sun.security.provider.certpath.PKIXMasterCertPathValidator.validate(Unknown Source)
         at sun.security.provider.certpath.PKIXCertPathValidator.doValidate(Unknown Source)
         at sun.security.provider.certpath.PKIXCertPathValidator.engineValidate(Unknown Source)
         at java.security.cert.CertPathValidator.validate(Unknown Source)
         ... 24 moreBelow is the source code of the program.
    package com.test.test;
    import java.security.Security;
    import java.util.Properties;
    import javax.mail.Authenticator;
    import javax.mail.Message;
    import javax.mail.MessagingException;
    import javax.mail.NoSuchProviderException;
    import javax.mail.PasswordAuthentication;
    import javax.mail.Session;
    import javax.mail.Transport;
    import javax.mail.internet.AddressException;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeMessage;
    public class JavaMailApp {
         public static void main( String[] args )
              String d_email = "[email protected]";
              String d_uname = "ots.support";
              String d_password = "password";
              String d_host = "mail.test.com";
              String d_port  = "465"; //465,587
              String m_to = "[email protected]";
              String m_subject = "Testing";
              String m_text = "Hey, this is the testing email.";
              Properties props = new Properties();
              props.put("mail.smtp.user", d_email);
              props.put("mail.smtp.host", d_host);
              props.put("mail.smtp.port", d_port);
              props.put("mail.smtp.starttls.enable","true");
              props.put("mail.smtp.debug", "true");
              props.put("mail.smtp.auth", "true");
              props.put("mail.smtp.socketFactory.port", d_port);
              props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
              props.put("mail.smtp.socketFactory.fallback", "false");
              SMTPAuthenticator auth = new SMTPAuthenticator();
              Session session = Session.getInstance(props, auth);
              session.setDebug(true);
              MimeMessage msg = new MimeMessage(session);
              try {
                   msg.setText(m_text);
                   msg.setSubject(m_subject);
                   msg.setFrom(new InternetAddress(d_email));
                   msg.addRecipient(Message.RecipientType.TO, new InternetAddress(m_to));
                   Transport transport = session.getTransport("smtps");
                   transport.connect(d_host, 465, d_uname, d_password);
                   transport.sendMessage(msg, msg.getAllRecipients());
                   transport.close();
              } catch (MessagingException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
    public class SMTPAuthenticator extends Authenticator{
         public PasswordAuthentication getPasswordAuthentication()
            return new PasswordAuthentication("[email protected]", "password");
    }I have also added the certificate to my keystore using the following command and still i am facing this issue.
    keytool -import -trustcacerts -alias root -file mail_test_com.crt -keystore keystore.jks
    Add to fierof2's Reputation

    this is where i created the keystore.jks file
    I navigated to the location C:\Program Files\Java\jdk1.6.0_13\bin in command prompt and typed the following command to create the keystore
    keytool -import -trustcacerts -alias root -file mail_test_com.crt -keystore keystore.jksI was asked to set the password for keystore and then i was asked the question "Trust this certificate? [no]:" for which i gave yes.
    If this is not the right place to create the keystore.jks can you please tell me what is correct location to create the keystore file.

  • How to send attachments using java application and outlook

    Hi ,
    I created an application in java which is as
    on the Conference Tab i can schedule a conference and with the send command on page it map all the scheduled data to outlook(with all conference details) and using outlook send option the mails are send to appropriate user.
    but now i want to modify this application such as when i use the send command from my jsp page it should attach the file that is in .vcs or .ics format for auto updation of user calender.
    can any one know how to send attachment using java application .

    Last time I checked, SMS was a service between carriers and doing SMS yourself was really tricky. Some services existed to let you do it but as I recall they wanted non-trivial money.
    However, most phone carriers provide an email-to-SMS bridge of some kind.
    So the easiest thing is just to send an email.
    That's sending from a non-phone to a phone. There's a J2ME library to send/receive SMS from/to a phone.
    However, this is from memory, and a little out of date, so I could be entirely wrong. Hope it helps anyway.

  • Sending mail in java using sendmail programme of lynix

    Hi,
    How can I send mail using Java and lynux "sendmail" programme located at i.e sendmail: /usr/sbin/sendmail.
    I don't want to use JavaMail API for sending. I want to use sendmail of lynix server. Plz help me. It's very uregent.
    Regards,
    Devom

    Hey Guys, here is the workaround for sending mails in java through javamail program of linux/unix:
    step 1 - Create a shell script which sends the mail using the 'sendmail' program. I have written below code in my shell script:
    #!/bin/sh
    #script to send simple email
    # email subject
    SUBJECT="Test Subject"
    # Email To ?
    EMAIL="[email protected],[email protected]"
    # Email text/message. This file will be automatically created and all text will be appended in it.
    EMAILMESSAGE="/tmp/emailmessage.txt"
    echo "This is a sample mai text."> $EMAILMESSAGE
    echo "And this is a also." >>$EMAILMESSAGE
    echo " " >>$EMAILMESSAGE
    echo " " >>$EMAILMESSAGE
    echo "Thanks & Regards," >>$EMAILMESSAGE
    echo "--Your Name" >>$EMAILMESSAGE
    mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE
    So create this script and save it as 'sendmail.sh' name in the same directory where you are executing your main java class. Please also note that this file should have full executable permissions for the program which is using this file.
    Step 2- Here is my Java code that executed this shell script:
    public void sendEmail()
    String operatingSystemProp = "os.name";
    String operatingSystemName = System.getProperty(operatingSystemProp);
    if(!operatingSystemName.startsWith("Windows"))
    String cmd = "./sendmail.sh";//unix shell script
    try
         Runtime.getRuntime().exec(cmd);
    }catch (Exception e)
         e.printStackTrace();
    You just need to call this method in your java code. This method will actually pick that shell script in runtime and will execute it, the rest will be handled by the shell script itself.
    So this workaround works fine for me and now I am sending mails through my java program using sendmail.
    Cheers!

  • How to send mail in PL/SQL using exchange server details.

    Hi Experts,
    Business user has provided us the exchange server details to send mails.How can I send mails thru PL/SQL using exchange server details.

    user595740 wrote:
    Business user has provided us the exchange server details to send mails.How can I send mails thru PL/SQL using exchange server details.Basic answer - not easily.
    Oracle supports the standard application protocol SMTP - it does not support a proprietary protocol like that used by Exchange that only works on the Windows operating system. It however provides you with the flexibility to code this yourself.
    If you for example use Microsoft MAPI (Mail Application Programming Interface), you can integrate it with PL/SQL using the external procedure (extproc) feature of Oracle.
    In a nutshell, extproc enables you to create PL/SQL wrappers for public DLL calls. I posted sample code that demonstrates this in {message:id=2271919}. The sample code is for calling a DLL interface on HP-UX, but the concept is identical on Windows.

  • How to send mail in  HTML  format using SMTP

    I want to send mail in HTML format using SMTP.Can anybody please suggest how to do it.Can anybody send me the code.
    Thnx.

    If you don't know how to send a message using JavaMail see here : http://developer.java.sun.com/developer/onlineTraining/JavaMail/contents.html#JavaMailSending
    To send a html format mail you need to set the content type like this (msg is a javax.mail.internet.MimeMessage) :
    String subject = "An Email 4 U";
    String message = "<HTML><BODY>Here is a link<br><a href='http://javasoft.com'>Java</a></BODY></HTML>";
    msg.setSubject(subject);
    msg.setContent(message, "text/html");p.s This isn't really an advanced topic

  • Java Application using Swig Running Visual C++ 6.0

    i,
    I am using Swig with Java ,I'm trying launch a Java application using a Windows executable,
    I'm using VC++6.0, and followed the instruction in Swig Documentation chaper 20,Section 20.2.8.
    I Build my dll in Vc++ i get this error Anyone know this,please help me.
         SWIG
         Compiling resources...
         Compiling...
         StdAfx.cpp
         Compiling...
         example.c
         Generating Code...
         Compiling...
         example_wrap.cpp
    c:\program files\java\jdk1.5.0_01\include\jni.h(46) : error C2146: syntax error : missing ';' before identifier 'jsize'
    c:\program files\java\jdk1.5.0_01\include\jni.h(46) : fatal error C1004: unexpected end of file found
    Generating Code...
    Error executing cl.exe.
    example.dll - 2 error(s), 0 warning(s)
    Regards
    Devi

    check on line 46, there might be a missing ";"
    c:\program files\java\jdk1.5.0_01\include\jni.h(46) : error C2146: syntax error : missing ';' before identifier 'jsize'

  • Problem Web Dynpro Java applications using JasperReports

    Hello all,
    We have followed the footsteps of these blogs but we can not make it work.
    Part I --> Part-I: Print Web Dynpro Java applications using JasperReports
    Part II --> Part-II: Print Web Dynpro Java applications using JasperReports
    Part III --> Part-III: Print Web Dynpro Java applications using JasperReports
    Details system: 7.02 SP3
    We believe that the problem is in the library, because it finds them.
    1) We created project as a DC external library with *.jars
    2) Public part DC external library.
    3) Add public part of DC Library into new project DC WebDynpro Java.
    4) Development Component -> Build is OK
    5) Development Component -> Deploy is OK
    6) Test app ERROR.
    When we run the application shows the error:
    The initial exception that caused the request to fail, was:
       java.lang.NoClassDefFoundError: net/sf/jasperreports/engine/JRDataSource
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:141)
        at com.unisys.tmb.View01.onActiongenerarPDF(View01.java:161)
        at com.unisys.tmb.wdp.InternalView01.wdInvokeEventHandler(InternalView01.java:140)
        at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:87)
        ... 28 more
    See full exception chain for details.
    Regards,
    Luis.

    Hello John,
    Thanks for the link. We have performed the steps in this blog:
    1) Create DC Project "External Library" with name js/jars:
    - Add *.jars in folder Libraries.[Screenshot Libraries|http://img846.imageshack.us/img846/8395/jsjars.jpg]
    - Add archives (*.jar) to public part with name ExternalLib. Which option to choose?
    a- Provides an API for developing/compiling other DCs (Option chosen)
    b- Can be packaged into other build results (eg SDAs)
    - Development Component -&gt; Build
    Step 1 is OK.
    2) Create "J2EE Server Component / Library" DC with name js/lib:
    - Add Used DC -> public part project ExternalLibrary -> "ExternalLib"
    - Specify both build time and run-time dependency here and strong.
    - Generated SDA file in <var>gen/default/deploy</var> How do we check that it contains <var>js.jar</var>?
    - folder gen/default/plublic/defLib/lib/java then you meet *.jars files again. is OK.
    - Development Component -> Deploy.
    - Go to Visual Administrator. We found the library js/lib, but has no associated *. jar. It is the problem.[Screenshot Visual Administrator|http://img542.imageshack.us/img542/5537/visualadminlib.jpg]
    3) Create "WebDynpro" DC with name pdf_jasper
    - Add used DC (defLib) to WebDynpro DC with option "Build time".
    - WebDynpro References -> Library references --> add <var>jslib
    - Deploy
    - Run error: java.lang.NoClassDefFoundError: net/sf/jasperreports/engine/JRDataSource
    Regards,
    Luis.

  • Load java applications using PXE or bootp

    hi... i was trying to test the option of booting up a java application using PXE or bootp.. is it possible to do so?? what are the rcommended ways to do it??
    Thanks
    Leonard

    Normal CORBA (as in Java IDL) is probably way too complicated for what you're trying to do, unless you're thinking of someday having the programs talk with non-Java programs.
    I'd start with Java RMI rather than RMI-IIOP since you can probably find more tutorials and docs on it (though the RMI-IIOP 1.4 docs here are really quite good). That way, you're writing everything in Java, at least.
    For remote object systems, all the advantaged of object oriented programming come into play, especially extensibility. What if you need to change the wire format to add more information in your socket system but need to maintain compatibility with older clients? What if you need to add security or handle multiple clients at once? What if you'd rather rely on existing serialization methods rather than code your own wire format for everything you want to send (making you write more code)? You can serialize any Java Serializable over Java RMI. That lets you send things without violating encapsulation. What if you want to talk to programs that aren't written in Java? What about automatic failure recovery if the server crashes? etc etc.

  • How can i call a VB6 project from my java application using JNI

    hi
    can anyone tell me the procedure of calling a VB6 project from any java application using JNI
    if anyone does know then tell me the detail procedure of doing that. I know that i have to create a dll of that VB6 project then to call it from the java application.
    if anyone know that procedure of creating dll file of an existing VB6 project please reply
    please if anyone know then let me know

    Ahh, kind of a duplicate thread:
    http://forums.java.sun.com/thread.jspa?threadID=631642
    @OP. You could have clarified your original post and the relationship of your question to java. You did not need a new thread.
    � {�                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to send mails to multiple recipents using SO_DOCUMENT_SEND_API

    Hi ,
    I am using the FM "SO_DOCUMENT_SEND_API".
    I am able to send an Excel sheet as attachement, but my requirement is to send multiple mails to the corresponding persons. I tried using coma, colan, semi colan as the separator in the import parameter SENDER_ADDRESS for two different mail id's but it was not useful.
    I need to send mails to multiple recipens using the same FM. (keeping one person in to list and two of the persons in CC.)
    can any on throw some light on this. 
    Thanks
    rewards will be great.....................................

    Hi,
    The code below demonstrates how to send an email to an external email address([email protected]),
    where the data is stored within a .xls attachment.
    Instead of the statement, <b>PARAMETERS: p_email   TYPE somlreci1-receiver
                                      DEFAULT '[email protected]'.</b>,
      use select-options & give the e-mail addresses that you want.
    *& Report  ZEMAIL_ATTACH                                               *
    *& Example of sending external email via SAPCONNECT                    *
    REPORT  ZEMAIL_ATTACH                   .
    TABLES: ekko.
    PARAMETERS: p_email   TYPE somlreci1-receiver
                                      DEFAULT '[email protected]'.
    TYPES: BEGIN OF t_ekpo,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
    END OF t_ekpo.
    DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0,
          wa_ekpo TYPE t_ekpo.
    TYPES: BEGIN OF t_charekpo,
      ebeln(10) TYPE c,
      ebelp(5)  TYPE c,
      aedat(8)  TYPE c,
      matnr(18) TYPE c,
    END OF t_charekpo.
    DATA: wa_charekpo TYPE t_charekpo.
    DATA:   it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                    WITH HEADER LINE.
    DATA:   it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                    WITH HEADER LINE.
    DATA:   t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
            t_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
            t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
            t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
            t_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE,
            w_cnt TYPE i,
            w_sent_all(1) TYPE c,
            w_doc_data LIKE sodocchgi1,
            gd_error    TYPE sy-subrc,
            gd_reciever TYPE sy-subrc.
    *START_OF_SELECTION
    START-OF-SELECTION.
      Retrieve sample data from table ekpo
      PERFORM data_retrieval.
      Populate table with detaisl to be entered into .xls file
      PERFORM build_xls_data_table.
    *END-OF-SELECTION
    END-OF-SELECTION.
    Populate message body text
      perform populate_email_message_body.
    Send file by email as .xls speadsheet
      PERFORM send_file_as_email_attachment
                                   tables it_message
                                          it_attach
                                    using p_email
                                          'Example .xls documnet attachment'
                                          'XLS'
                                          'filename'
                                 changing gd_error
                                          gd_reciever.
      Instructs mail send program for SAPCONNECT to send email(rsconn01)
      PERFORM initiate_mail_execute_program.
    *&      Form  DATA_RETRIEVAL
          Retrieve data form EKPO table and populate itab it_ekko
    FORM data_retrieval.
      SELECT ebeln ebelp aedat matnr
       UP TO 10 ROWS
        FROM ekpo
        INTO TABLE it_ekpo.
    ENDFORM.                    " DATA_RETRIEVAL
    *&      Form  BUILD_XLS_DATA_TABLE
          Build data table for .xls document
    FORM build_xls_data_table.
      CONSTANTS: con_cret TYPE x VALUE '0D',  "OK for non Unicode
                 con_tab TYPE x VALUE '09'.   "OK for non Unicode
    *If you have Unicode check active in program attributes thnen you will
    *need to declare constants as follows
    *class cl_abap_char_utilities definition load.
    *constants:
       con_tab  type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
       con_cret type c value cl_abap_char_utilities=>CR_LF.
      CONCATENATE 'EBELN' 'EBELP' 'AEDAT' 'MATNR'
             INTO it_attach SEPARATED BY con_tab.
      CONCATENATE con_cret it_attach  INTO it_attach.
      APPEND  it_attach.
      LOOP AT it_ekpo INTO wa_charekpo.
        CONCATENATE wa_charekpo-ebeln wa_charekpo-ebelp
                    wa_charekpo-aedat wa_charekpo-matnr
               INTO it_attach SEPARATED BY con_tab.
        CONCATENATE con_cret it_attach  INTO it_attach.
        APPEND  it_attach.
      ENDLOOP.
    ENDFORM.                    " BUILD_XLS_DATA_TABLE
    *&      Form  SEND_FILE_AS_EMAIL_ATTACHMENT
          Send email
    FORM send_file_as_email_attachment tables pit_message
                                              pit_attach
                                        using p_email
                                              p_mtitle
                                              p_format
                                              p_filename
                                              p_attdescription
                                              p_sender_address
                                              p_sender_addres_type
                                     changing p_error
                                              p_reciever.
      DATA: ld_error    TYPE sy-subrc,
            ld_reciever TYPE sy-subrc,
            ld_mtitle LIKE sodocchgi1-obj_descr,
            ld_email LIKE  somlreci1-receiver,
            ld_format TYPE  so_obj_tp ,
            ld_attdescription TYPE  so_obj_nam ,
            ld_attfilename TYPE  so_obj_des ,
            ld_sender_address LIKE  soextreci1-receiver,
            ld_sender_address_type LIKE  soextreci1-adr_typ,
            ld_receiver LIKE  sy-subrc.
      ld_email   = p_email.
      ld_mtitle = p_mtitle.
      ld_format              = p_format.
      ld_attdescription      = p_attdescription.
      ld_attfilename         = p_filename.
      ld_sender_address      = p_sender_address.
      ld_sender_address_type = p_sender_addres_type.
    Fill the document data.
      w_doc_data-doc_size = 1.
    Populate the subject/generic message attributes
      w_doc_data-obj_langu = sy-langu.
      w_doc_data-obj_name  = 'SAPRPT'.
      w_doc_data-obj_descr = ld_mtitle .
      w_doc_data-sensitivty = 'F'.
    Fill the document data and get size of attachment
      CLEAR w_doc_data.
      READ TABLE it_attach INDEX w_cnt.
      w_doc_data-doc_size =
         ( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
      w_doc_data-obj_langu  = sy-langu.
      w_doc_data-obj_name   = 'SAPRPT'.
      w_doc_data-obj_descr  = ld_mtitle.
      w_doc_data-sensitivty = 'F'.
      CLEAR t_attachment.
      REFRESH t_attachment.
      t_attachment[] = pit_attach[].
    Describe the body of the message
      CLEAR t_packing_list.
      REFRESH t_packing_list.
      t_packing_list-transf_bin = space.
      t_packing_list-head_start = 1.
      t_packing_list-head_num = 0.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE it_message LINES t_packing_list-body_num.
      t_packing_list-doc_type = 'RAW'.
      APPEND t_packing_list.
    Create attachment notification
      t_packing_list-transf_bin = 'X'.
      t_packing_list-head_start = 1.
      t_packing_list-head_num   = 1.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
      t_packing_list-doc_type   =  ld_format.
      t_packing_list-obj_descr  =  ld_attdescription.
      t_packing_list-obj_name   =  ld_attfilename.
      t_packing_list-doc_size   =  t_packing_list-body_num * 255.
      APPEND t_packing_list.
    Add the recipients email address
      CLEAR t_receivers.
      REFRESH t_receivers.
      t_receivers-receiver = ld_email.
      t_receivers-rec_type = 'U'.
      t_receivers-com_type = 'INT'.
      t_receivers-notif_del = 'X'.
      t_receivers-notif_ndel = 'X'.
      APPEND t_receivers.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
           EXPORTING
                document_data              = w_doc_data
                put_in_outbox              = 'X'
                sender_address             = ld_sender_address
                sender_address_type        = ld_sender_address_type
                commit_work                = 'X'
           IMPORTING
                sent_to_all                = w_sent_all
           TABLES
                packing_list               = t_packing_list
                contents_bin               = t_attachment
                contents_txt               = it_message
                receivers                  = t_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.
    Populate zerror return code
      ld_error = sy-subrc.
    Populate zreceiver return code
      LOOP AT t_receivers.
        ld_receiver = t_receivers-retrn_code.
      ENDLOOP.
    ENDFORM.
    *&      Form  INITIATE_MAIL_EXECUTE_PROGRAM
          Instructs mail send program for SAPCONNECT to send email.
    FORM initiate_mail_execute_program.
      WAIT UP TO 2 SECONDS.
      SUBMIT rsconn01 WITH mode = 'INT'
                    WITH output = 'X'
                    AND RETURN.
    ENDFORM.                    " INITIATE_MAIL_EXECUTE_PROGRAM
    *&      Form  POPULATE_EMAIL_MESSAGE_BODY
           Populate message body text
    form populate_email_message_body.
      REFRESH it_message.
      it_message = 'Please find attached a list test ekpo records'.
      APPEND it_message.
    endform.                    " POPULATE_EMAIL_MESSAGE_BODY
    Hope this helps.
    Reward if helpful.
    Regards,
    Sipra

  • Can we run a java application using Runtime.exec()?

    Can we run a java application using Runtime.exec()?
    If yes what should i use "java" or "javaw", and which way?
    r.exec("java","xyz.class");

    The best way to run the java application would be to dynamiically load it within the same JVM. Look thru the class "ClassLoader" and the "Class", "Method" etc...clases.
    The problem with exec is that it starts another JVM and moreover you dont have the interface where you can throw the Output directly.(indirectly it can be done by openong InputStreams bala blah............). I found this convenient. I am attaching part of my code for easy refernce.
    HIH
    ClassLoader cl = null;
    Class c = null;
    Class cArr[] ;
    Method md = null;
    Object mArr[];
    cl = ClassLoader.getSystemClassLoader();
    try{
         c = cl.loadClass(progName.substring(0,progName.indexOf(".class")) );
    } catch(ClassNotFoundException e) {
    System.out.println(e);
         cArr = new Class[1] ;
         try{
         cArr[0] = Class.forName("java.lang.Object");
         } catch(ClassNotFoundException e) {
         System.out.println(e);
         mArr = new Object[1];
         try{
         md = c.getMethod("processPkt", cArr);
         } catch(NoSuchMethodException e) {
         System.out.println(e);
         } catch(SecurityException e) {
         System.out.println(e);
    try {            
    processedPkt = md.invoke( null, mArr) ;
    } catch(IllegalAccessException e) {
              System.out.println(e);
    } catch(IllegalArgumentException e) {
              System.out.println(e);
    }catch(InvocationTargetException e) {
              System.out.println(e);
    }catch(NullPointerException e) {
              System.out.println(e);
    }catch(ExceptionInInitializerError e) {
              System.out.println(e);
    }

  • We have a requirement to print the w2 forms for employees using java application, how can i implement this. Please give some suggestion.

    We have a requirement to print the w2 forms for employees using java application, how can i implement this. Please give some suggestion.

    Anyone any ideas to help please?

Maybe you are looking for