Hi... My code to send mail is executing before calling it.....???

Hi friends.....
I hope you are all fine.
I have a new problem for you to solve...
I'm using a piece of code to send a mail from my JSP file, which will be called when a button is clicked...
This mail code is running when the JSP page loads... without clicking the button...
Any solution.....??
Please help.... urgent..
Thanks in advance.....

PraveenKumarJ wrote:
Yes...
I'm still a trainee..
...............okay.....................
I'm still learning things right......okay...........................
We have been assigned a project.............that.....was..........a................mistake.....it..........seeems.......you.....are...not.........ready
>
Anyway thanks for your replies...........you....'....re......welcome!!!!
>
Thanks...perhaps......you.....could.....in.......future.......have.......less...of....these???????????????

Similar Messages

  • Workflow to send mail 20 day before the expiry date

    Dear All,
    I created a workflow to send mail when a calculated column date is equal to today as follows:-
    Step1
    add -20 days  to Current Item:Expiry Date (Output to Variable : date)
    then set variable : Notification1 to Variable : date
    Step2
    If variable:notification1 equals (ignoring time) Today
    email users
    Now when i add a new item to the list , the workflow status is set to In progress , and when i refresh the page the status is changed to Completed before the condition is met and!!
    Any help
    Regards

    If I Understood your question correctly, you need to send email to user 20 days before expiration date. 
    From above you workflow I can see, you are just checking your condition once a item is created. As your Step2 condition is not met your  workflow is completed without any error. I suggest you might want to try below workflow
    Step1
    add -20 days  to Current Item:Expiry Date (Output to Variable : date)
    then set variable : Notification1 to Variable : date
    then Pause until Variable:date
    Step2
    email users
    Above workflow design will pause you workflow till 20 days before expiry date. and then send email to user. 
    Please ignore syntax, I just tried to put logic.
    Below is explantion on how to use Pause Action(from MSDN) in Sharepoint workflow
    This action is initially displayed in a workflow step as Pause until this time.
    Use this action to pause the workflow until a particular date. You can add a current date, a specific date, or a lookup.
    Following are examples of what the action might look like in a workflow step,
    Pause until 1/1/2010 12:00:00 AM
    Pause until Variable: A week from Modified
    If this helps Please mark it answer or vote as helpful.
    Thanks
    Siddharth

  • How to send mail from ABAP code?

    Hi,
    I need to send e-mail from ABAP Code .
    e.g:  If sy-subrc ne 0.
         ( send e-mail to  "[email protected]" )
           endif.
    Please provide me any Function module for this or any code.
    Correct answear will be rewarded my maximum points.
    Thanks & Regards,
    Gaurav.

    Check this code sample
    * Send mail
      maildata-obj_name = 'TEST'.
      maildata-obj_descr = 'Test Subject'.
      loop at htmllines.
        mailtxt = htmllines.
        append mailtxt.
      endloop.
      mailrec-receiver = '[email protected]'.
      mailrec-rec_type  = 'U'.
      append mailrec.
      call function 'SO_NEW_DOCUMENT_SEND_API1'
           exporting
                document_data              = maildata
                document_type              = 'HTM'
                put_in_outbox              = 'X'
           tables
                object_header              = mailtxt
                object_content             = mailtxt
                receivers                  = mailrec
           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.

  • Send mail to external mail address

    Hello Guys,,
    I have required to send a mail through abap code. This program is need to schedule.
    Can some one send  me some sample code to send mail..
    I have search with existing forum , but have'nt got any proper answer.
    Thanks
    Swati....

    Hi i am sending 2 programs
    <b>First program......</b>
    REPORT  YH647_PRJ_TEST1 line-count 1000.
    data:
      fs_abaplist like abaplist.
    *DATA W_RULE(2) TYPE X VALUE '2009'.
    data:
    t_list like standard table
              of abaplist.
    DATA:
      T_DATA(1000) OCCURS 0,
      fs_data(1000).
    DATA:
       doc_chng like sodocchgi1,
       objpack like sopcklsti1 occurs 0 with header line,
       objhead like solisti1 occurs 0 with header line,
       objbin like solisti1 occurs 0 with header line,
       objtxt like solisti1 occurs 0 with header line,
       reclist like somlreci1 occurs 0 with header line,
       eml_tab like w3html occurs 0 with header line,
       eml_lines like sy-tabix,
       l_t_lines like tline occurs 0 with header line,
       tab_lines like sy-tabix.
    submit YH647_PRJ_TEST2 and return.
      import t_list from memory id 'MAN'.
    loop at t_list into fs_abaplist.
        condense fs_abaplist.
       TRANSLATE fs_abaplist using w_rule.
        write : / fs_abaplist.
      endloop.
    T_DATA[] = T_LIST[].
    CALL FUNCTION 'GUI_DOWNLOAD'
       EXPORTING
       BIN_FILESIZE                    =
         FILENAME                        = 'D:\test\PRJ1.XLS'
         FILETYPE                        = 'ASC'
       APPEND                          = ' '
        WRITE_FIELD_SEPARATOR           = ''
       HEADER                          = '00'
       TRUNC_TRAILING_BLANKS           = ' '
       WRITE_LF                        = 'X'
       COL_SELECT                      = ' '
       COL_SELECT_MASK                 = ' '
       DAT_MODE                        = ' '
       CONFIRM_OVERWRITE               = ' '
       NO_AUTH_CHECK                   = ' '
       CODEPAGE                        = ' '
       IGNORE_CERR                     = ABAP_TRUE
       REPLACEMENT                     = '#'
       WRITE_BOM                       = ' '
       TRUNC_TRAILING_BLANKS_EOL       = 'X'
       WK1_N_FORMAT                    = ' '
       WK1_N_SIZE                      = ' '
       WK1_T_FORMAT                    = ' '
       WK1_T_SIZE                      = ' '
    IMPORTING
       FILELENGTH                      =
       TABLES
         DATA_TAB                        = T_DATA
       FIELDNAMES                      =
      EXCEPTIONS
        FILE_WRITE_ERROR                = 1
        NO_BATCH                        = 2
        GUI_REFUSE_FILETRANSFER         = 3
        INVALID_TYPE                    = 4
        NO_AUTHORITY                    = 5
        UNKNOWN_ERROR                   = 6
        HEADER_NOT_ALLOWED              = 7
        SEPARATOR_NOT_ALLOWED           = 8
        FILESIZE_NOT_ALLOWED            = 9
        HEADER_TOO_LONG                 = 10
        DP_ERROR_CREATE                 = 11
        DP_ERROR_SEND                   = 12
        DP_ERROR_WRITE                  = 13
        UNKNOWN_DP_ERROR                = 14
        ACCESS_DENIED                   = 15
        DP_OUT_OF_MEMORY                = 16
        DISK_FULL                       = 17
        DP_TIMEOUT                      = 18
        FILE_NOT_FOUND                  = 19
        DATAPROVIDER_EXCEPTION          = 20
        CONTROL_FLUSH_ERROR             = 21
        OTHERS                          = 22
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    OBJBIN[] =  T_DATA.
      DOC_CHNG-OBJ_NAME = 'OFFER'.
      DOC_CHNG-OBJ_DESCR = 'Test Program List Output'.
      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)
       DESCRIBE TABLE OBJBIN LINES TAB_LINES.
       OBJHEAD = 'OUTPUT.XLS'. 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   = 'RAW'.
       OBJPACK-OBJ_NAME   = 'ATTACHMENT'.
       OBJPACK-OBJ_DESCR = 'Test program output'.
       OBJPACK-DOC_SIZE   = TAB_LINES * 255.
       APPEND OBJPACK..
    ***Recepients List
       reclist-receiver = 'SAPDEV17'.
       reclist-rec_type = 'B'.
       APPEND reclist.
        reclist-receiver = '[email protected]'.
        reclist-rec_type = 'U'.
        APPEND reclist.
    Sending the document
      call function 'SO_DOCUMENT_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 of recipients!'
          raise too_many_recievers.
        when 2.
          write: / 'document could not be sent to any of the recipients!'.
          raise document_not_sent.
        when 4.
          write: / 'no authorization to send !'.
          raise operation_no_authorization.
        when others.
          write: / 'error occurred during sending !'.
          raise others.
      endcase.
    <b>Second program......</b>
    REPORT  YH647_PRJ_TEST2.
    TABLES:
      SFLIGHT.
    data:
    t_list like standard table
              of abaplist.
    *DATA:
    T_DATA(1000) OCCURS 0,
    fs_data(1000).
      DATA: BEGIN OF FS_DATA  OCCURS 0,
              MANDT TYPE SFLIGHT-MANDT,
              CARRID TYPE SFLIGHT-CARRID,
              CONNID TYPE SFLIGHT-CONNID,
              FLDATE TYPE SFLIGHT-FLDATE,
              PRICE(15)  TYPE C,
              CURRENCY TYPE SFLIGHT-CURRENCY,
              PLANETYPE TYPE SFLIGHT-PLANETYPE,
              SEATSMAX(10) TYPE C,
              SEATSOCC(10) TYPE C,
              PAYMENTSUM(17) TYPE C,
              SEATSMAX_B(10) TYPE C,
              SEATSOCC_B(10) TYPE C,
              SEATSMAX_F(10) TYPE C,
              SEATSOCC_F(10) TYPE C,
            END OF FS_DATA.
    DATA:
      T_DATA LIKE TABLE OF FS_DATA.
    data:
      T_SFLIGHT like table of sFLIGHT.
    select * into
           SFLIGHT
      up to 200 rows
       from sflight.
    MOVE-CORRESPONDING SFLIGHT TO FS_DATA.
    APPEND FS_DATA TO T_DATA.
    ENDSELECT.
    t_list[] = t_DATA[].
    *move t_data to t_list.
    export t_list to memory id 'MAN'.
    execute the first program......
    Reward points if useful......
    Suresh......

  • Sending mail using javamail

    Hi!
    I am new to JavaMail and trying to execute a simple code to send mail.
    I can compile the code without any errors. But when I try to run it, I get following error:
    Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/MessagingException
    I have my mail.jar and activation.jar in \lib\ext.
    the code is demo code from sun, in their demo files that one gets with javamail.
    Thanks,
    bandya

    You have to put the paths if mail.jar and activation.jar in the system CLASSPATH.
    or you can do this before executing the java program
    in command prompt
    set CLASSPATH=%CLASSPATH%;c:\mail.jar;c:\activation.jar
    assuming the jar are in c:\ .

  • Sending mail through a proxy client

    I have the following simple code to send mail through a SOCKS proxy client:
    package com.apna.beans;
    import java.util.Properties;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.activation.DataSource;
    import javax.activation.FileDataSource;
    import javax.activation.DataHandler ;
    public class SMail{
    public static void main(String[]a){
    System.setProperty("proxySet","true");
    /*System.getProperties().put("http.proxyPort","25");
    System.getProperties().put("http.proxyHost","192.168.0.1");*/
    Properties props = System.getProperties();
    String msg = "";
    // Get system properties
    final String username = "vedijitendra";
    final String password = "sendmail";
    props.put("socksProxyHost", "pc-2");
    props.put("socksProxyPort", "1080");
    props.put("mail.smtp.host", "smtp.gmail.com");
    props.put("mail.smtp.starttls.enable", "true");
    props.put("mail.user", username);
    props.put("mail.smtp.auth","true"); // this is imp for authorisation.
    //props.put("mail.host", "192.168.0.1");
    props.put("mail.debug", "true");
    props.put("mail.store.protocol", "pop3");
    props.put("mail.transport.protocol", "smtp");
    try{
    //here the authorisation takes place using an Anonymous class.
    Session session = Session.getDefaultInstance(props,
    new javax.mail.Authenticator (){
    protected
    javax.mail.PasswordAuthentication
    getPasswordAuthentication() {
    return new
    javax.mail.PasswordAuthentication(username,
    password);
    // Define message
    Message message = new MimeMessage(session);
    message.setFrom(new InternetAddress("[email protected]"));
    message.addRecipient( Message.RecipientType.TO, new
    InternetAddress("[email protected]"));
    message.setSubject("Test");
    message.setContent("text", "text/html");
    // Send the message
    Transport.send(message);
    msg = "The mail has been sent.";
    } catch(Exception e){
    e.printStackTrace();
    msg = "The mail has not been sent.";
    I am able to connect to the GMail's SMTP server.
    However, when the Transport. send method is executed, I get:
    java.lang.NullPointerException
    at com.sun.mail.util.SocketFetcher.startTLS(SocketFetcher.java:242)
    at com.sun.mail.smtp.SMTPTransport.startTLS(SMTPTransport.java:1191)
    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:348)
    at javax.mail.Service.connect(Service.java:297)
    at javax.mail.Service.connect(Service.java:156)
    at javax.mail.Service.connect(Service.java:105)
    at javax.mail.Transport.send0(Transport.java:168)
    at javax.mail.Transport.send(Transport.java:98)
    Any ideas?

    I have the following simple code to send mail through a SOCKS proxy client:
    package com.apna.beans;
    import java.util.Properties;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.activation.DataSource;
    import javax.activation.FileDataSource;
    import javax.activation.DataHandler ;
    public class SMail{
    public static void main(String[]a){
    System.setProperty("proxySet","true");
    /*System.getProperties().put("http.proxyPort","25");
    System.getProperties().put("http.proxyHost","192.168.0.1");*/
    Properties props = System.getProperties();
    String msg = "";
    // Get system properties
    final String username = "vedijitendra";
    final String password = "sendmail";
    props.put("socksProxyHost", "pc-2");
    props.put("socksProxyPort", "1080");
    props.put("mail.smtp.host", "smtp.gmail.com");
    props.put("mail.smtp.starttls.enable", "true");
    props.put("mail.user", username);
    props.put("mail.smtp.auth","true"); // this is imp for authorisation.
    //props.put("mail.host", "192.168.0.1");
    props.put("mail.debug", "true");
    props.put("mail.store.protocol", "pop3");
    props.put("mail.transport.protocol", "smtp");
    try{
    //here the authorisation takes place using an Anonymous class.
    Session session = Session.getDefaultInstance(props,
    new javax.mail.Authenticator (){
    protected
    javax.mail.PasswordAuthentication
    getPasswordAuthentication() {
    return new
    javax.mail.PasswordAuthentication(username,
    password);
    // Define message
    Message message = new MimeMessage(session);
    message.setFrom(new InternetAddress("[email protected]"));
    message.addRecipient( Message.RecipientType.TO, new
    InternetAddress("[email protected]"));
    message.setSubject("Test");
    message.setContent("text", "text/html");
    // Send the message
    Transport.send(message);
    msg = "The mail has been sent.";
    } catch(Exception e){
    e.printStackTrace();
    msg = "The mail has not been sent.";
    I am able to connect to the GMail's SMTP server.
    However, when the Transport. send method is executed, I get:
    java.lang.NullPointerException
    at com.sun.mail.util.SocketFetcher.startTLS(SocketFetcher.java:242)
    at com.sun.mail.smtp.SMTPTransport.startTLS(SMTPTransport.java:1191)
    at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:348)
    at javax.mail.Service.connect(Service.java:297)
    at javax.mail.Service.connect(Service.java:156)
    at javax.mail.Service.connect(Service.java:105)
    at javax.mail.Transport.send0(Transport.java:168)
    at javax.mail.Transport.send(Transport.java:98)
    Any ideas?

  • Sending mail in PDF format in background

    Hi,
    I am running a program in backgorund.
    After the completion, I am convertin gthe spool into PDF format and sending it to mail.
    In SAP 4.6 B it was working.
    But now in SAP 4.7 the mail is not working.
    Regular mails are going from SAP.
    What could be the reason?.
    Regards
    Elini.P

    Dear Paul,
    Here is the code for sending mail through ABAP converting Spool in PDF in background.
      if sy-batch eq 'X'.
        perform get_job_details.
        perform obtain_spool_id.
        perform convert_spool_to_pdf.
        perform process_email.
        if p_delspl eq 'X'.
          perform delete_spool.
        endif.
        if sy-sysid = c_dev.
          wait up to 5 seconds.
          submit rsconn01 with mode = 'INT'
                          with output = 'X'
                                          and return.
        endif.
      else.
        skip.
        write:/ 'Program must be executed in background in-order for spool',
        'request to be created.'.
      endif.
    *&      Form  GET_JOB_DETAILS
          text
    -->  p1        text
    <--  p2        text
    form get_job_details.
    Get current job details
      call function 'GET_JOB_RUNTIME_INFO'
           importing
                eventid                 = gd_eventid
                eventparm               = gd_eventparm
                external_program_active = gd_external_program_active
                jobcount                = gd_jobcount
                jobname                 = gd_jobname
                stepcount               = gd_stepcount
           exceptions
                no_runtime_info         = 1
                others                  = 2.
    endform.                    " GET_JOB_DETAILS
    *&      Form  OBTAIN_SPOOL_ID
          text
    -->  p1        text
    <--  p2        text
    form obtain_spool_id.
      check not ( gd_jobname is initial ).
      check not ( gd_jobcount is initial ).
      select * from tbtcp into table it_tbtcp
      where jobname = gd_jobname
        and jobcount = gd_jobcount
        and stepcount = gd_stepcount
        and listident <> '0000000000'
        order by jobname
                 jobcount
                 stepcount.
      read table it_tbtcp into wa_tbtcp index 1.
      if sy-subrc = 0.
        message s004(zdd) with gd_spool_nr.
        gd_spool_nr = wa_tbtcp-listident.
        message s004(zdd) with gd_spool_nr.
      else.
        message s005(zdd).
      endif.
    endform.                    " OBTAIN_SPOOL_ID
    *&      Form  CONVERT_SPOOL_TO_PDF
          text
    -->  p1        text
    <--  p2        text
    form convert_spool_to_pdf.
      call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
           exporting
                src_spoolid              = gd_spool_nr
                no_dialog                = c_no
                dst_device               = c_device
           importing
                pdf_bytecount            = gd_bytecount
           tables
                pdf                      = it_pdf_output
           exceptions
                err_no_abap_spooljob     = 1
                err_no_spooljob          = 2
                err_no_permission        = 3
                err_conv_not_possible    = 4
                err_bad_destdevice       = 5
                user_cancelled           = 6
                err_spoolerror           = 7
                err_temseerror           = 8
                err_btcjob_open_failed   = 9
                err_btcjob_submit_failed = 10
                err_btcjob_close_failed  = 11
                others                   = 12.
      check sy-subrc = 0.
    Transfer the 132-long strings to 255-long strings
      loop at it_pdf_output.
        translate it_pdf_output using ' ~'.
        concatenate gd_buffer it_pdf_output into gd_buffer.
      endloop.
      translate gd_buffer using '~ '.
      do.
        it_mess_att = gd_buffer.
        append it_mess_att.
        shift gd_buffer left by 255 places.
        if gd_buffer is initial.
          exit.
        endif.
      enddo.
    endform.                    " CONVERT_SPOOL_TO_PDF
    *&      Form  PROCESS_EMAIL
          text
    -->  p1        text
    <--  p2        text
    form process_email.
      describe table it_mess_att lines gd_recsize.
      check gd_recsize > 0.
      perform send_email using p_email1.
    endform.                    " PROCESS_EMAIL
    *&      Form  SEND_EMAIL
          text
         -->P_P_EMAIL1  text
    form send_email using    p_email.
      check not ( p_email is initial ).
      refresh it_mess_bod.
    Default subject matter
      gd_subject = 'Subject'.
      gd_attachment_desc = 'Attachname'.
    CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
      it_mess_bod = 'SCGL - Purchase Order in 050'.
      append it_mess_bod.
      it_mess_bod = 'Success or Error messages'.
      append it_mess_bod.
    If no sender specified - default blank
      if p_sender eq space.
        gd_sender_type = space.
      else.
        gd_sender_type = 'INT'.
      endif.
    Add the recipients email address
      open dataset file for input in text mode.
      if sy-subrc = 0.
        do.
          read dataset file into itab_receivers.
          if sy-subrc = 0.
            append itab_receivers.
          else.
            exit.
          endif.
        enddo.
      endif.
      close dataset file.
      loop at itab_receivers.
        clear: p_email.
        p_email = itab_receivers-receiver.
    Send file by email as .xls speadsheet
        perform send_file_as_email_attachment
                          tables it_mess_bod
                                 it_mess_att
                           using p_email
                                'SCGL Purchase Order IN 050'
                                'PDF'
                                 gd_attachment_name
                                 gd_attachment_desc
                                 p_sender
                                 gd_sender_type
                        changing gd_error
                                 gd_reciever.
      endloop.
    endform.                    " SEND_EMAIL
    *&      Form  SEND_FILE_AS_EMAIL_ATTACHMENT
          text
         -->P_IT_MESS_BOD  text
         -->P_IT_MESS_ATT  text
         -->P_P_EMAIL  text
         -->P_1572   text
         -->P_1573   text
         -->P_GD_ATTACHMENT_NAME  text
         -->P_GD_ATTACHMENT_DESC  text
         -->P_P_SENDER  text
         -->P_GD_SENDER_TYPE  text
         <--P_GD_ERROR  text
         <--P_GD_RECIEVER  text
    form send_file_as_email_attachment tables it_message
                                              it_attach
                                       using p_email
                                             p_mtitle
                                             p_format
                                             p_filename
                                             p_attdescription
                                             p_sender_address
                                             p_sender_addres_type
                                       changing p_error
                                                p_reciever.
      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[] = it_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.                    " SEND_FILE_AS_EMAIL_ATTACHMENT
    *&      Form  DELETE_SPOOL
          text
    -->  p1        text
    <--  p2        text
    form delete_spool.
      data: ld_spool_nr type tsp01_sp0r-rqid_char.
      ld_spool_nr = gd_spool_nr.
      check p_delspl <> c_no.
      call function 'RSPO_R_RDELETE_SPOOLREQ'
           exporting
                spoolid = ld_spool_nr.
    endform.                    " DELETE_SPOOL

  • Sending mail to multiple recipients

    Hello friends,
    i have written java code for sending mail,its working fine for single mail address. if we include multiple mail address its giving ERROR:" Illegal route-addr in string" , so friends if there is any solution for this problem: please kindly reply. i have included sendmail->code and setproperty-> and the exact exception.
    SENDMAIL
    public boolean sendMail(User userObj, Message message, String content){
    try{
    util util=new util();
    String arr[]=util.getTokens(userObj.email,",");
    InternetAddress inetarr[]=new InternetAddress[arr.length];
    for(int i=0;i<arr.length;i++){
    inetarr=new InternetAddress(arr[i].toString());
    message.setRecipients(Message.RecipientType.TO, inetarr);
    MimeMultipart multipart=new MimeMultipart();
    BodyPart msgBodyPart=new MimeBodyPart();
    msgBodyPart.setContent(content, "text/html");
    multipart.addBodyPart(msgBodyPart);
    message.setContent(multipart);
    message.setSentDate(new Date());
    Transport.send(message);
    return true;
    }catch(Exception e){
    e.printStackTrace();
    return false;
    }//End Of The Method
    GETPROPRITIES
    protected Properties getProperties(){
         Properties props = new Properties();
         props.put("mail.smtp.starttls.enable","true");
         props.put("mail.transport.protocol", "smtp");
         props.put("mail.smtp.host", adminObj.info.server[0]);
         props.put("mail.smtp.port",adminObj.info.server_port[0]+"");
         props.put("mail.debug","false");
         props.put("mail.smtp.auth", "true");
         props.put("mail.smtp.quitwait", "false");
    props.put("mail.smtp.sendpartial", "true");
         return props;
    }//End Of The Method
    Exception
    javax.mail.internet.AddressException: Illegal route-addr in string ``saravana.07
    @gmail.com,[email protected]''
    at javax.mail.internet.InternetAddress.checkAddress(InternetAddress.java
    :883)
    at javax.mail.internet.InternetAddress.parse(InternetAddress.java:819)
    at javax.mail.internet.InternetAddress.parseHeader(InternetAddress.java:
    580)
    at javax.mail.internet.MimeMessage.getAddressHeader(MimeMessage.java:680
    at javax.mail.internet.MimeMessage.getFrom(MimeMessage.java:340)
    at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:897)
    at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:583)
    at javax.mail.Transport.send0(Transport.java:169)
    at javax.mail.Transport.send(Transport.java:98)
    at common.application.utilities.TenderMail.sendMail(TenderMail.java:483)
    at common.application.mail.send_user_mail.__BodhiReceive(send_user_mail.
    java:146)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
    java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at jdbs.BodhiServer.callStation(Unknown Source)
    at jdbs.BodhiSend.doSend(Unknown Source)
    at common.application.mail.sendmail.__BodhiReceive(sendmail.java:361)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
    java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at JumpForwarder1.callStation(JumpForwarder1.java:863)
    at JumpForwarder1.processRequest(JumpForwarder1.java:613)
    at JumpForwarder1.authenticateUserAndExecute(JumpForwarder1.java:254)
    at JumpForwarder1.doPost(JumpForwarder1.java:132)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
    icationFilterChain.java:284)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
    ilterChain.java:204)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
    alve.java:257)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
    eContext.java:151)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
    a:567)
    at org.apache.catalina.core.StandardContextValve.invokeInternal(Standard
    ContextValve.java:245)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
    alve.java:199)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
    eContext.java:151)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
    torBase.java:509)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
    eContext.java:149)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
    a:567)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
    ava:184)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
    eContext.java:151)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
    ava:164)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
    eContext.java:149)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
    a:567)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
    ve.java:156)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
    eContext.java:151)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
    a:567)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:20
    6)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
    :833)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
    ssConnection(Http11Protocol.java:732)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java
    :619)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
    ool.java:688)
    at java.lang.Thread.run(Thread.java:534)

    You seem to be splitting a string containing multiple addresses and constructing
    InternetAddress objects for each entry. But looking at the address it's complaining
    about, it looks like you failed to split the string properly. You might want to use the
    InternetAddress.parse method that will do the splitting for you.

  • Sending mail with multiple attachments

    hi.I wrote a code to send mail.but i need to send mail with multiple attachments.here is the code i wrote.what should i do to send the mail with multiple attachments.if i run this code iam able to send mails but not attachments.please help me
    <%@ page import="javax.mail.*,javax.mail.internet.*,java.util.Date,java.io.*,java.net.InetAddress,java.sql.*,java.util.Properties,java.net.*,javax.sql.*,javax.activation.*,java.util.*,java.text.*" %>
    <%@ page import="java.io.*,java.sql.*,java.net.*,java.util.*,java.text.*" %>
    <%
         String Attachfiles1="";
         String Attachfiles2="";
    String Attachfiles3="";
    if("Send".equalsIgnoreCase("send"))
              try
         String subject="",from="",url = null,to="";
         String mailhost = "our local host";
         Properties props = System.getProperties();
         String msg_txt="";
         String strStatus="";
    // byte[] bin=.....;
    //Adds Attechment:
    Multipart multipart = new MimeMultipart();
    BodyPart messageBodyPart = new MimeBodyPart();
    messageBodyPart.setText("Here are my attachments");
    multipart.addBodyPart(messageBodyPart);
    messageBodyPart = new MimeBodyPart();
    //first attachment
    DataSource source = new FileDataSource("C:\\img1.jpg");
    messageBodyPart.setDataHandler(new DataHandler(source));
    messageBodyPart.setFileName("C:\\Telnor1.jpg");
    multipart.addBodyPart(messageBodyPart);
    //Second attachment
    DataSource source2 = new FileDataSource("C:\\img2.jpg");
    messageBodyPart.setDataHandler(new DataHandler(source2));
    messageBodyPart.setFileName("C:\\Telnor2.jpg");
    multipart.addBodyPart(messageBodyPart);
    //etc...
    message.setContent(multipart);
    Transport.send( message );
    String mailer = "MyMailerProgram";
    to=request.getParameter("to");
    from=request.getParameter("from");
    subject=request.getParameter("subject");
    msg_txt=request.getParameter("message");
    props.put("mail.smtp.host", mailhost);
    Session mailsession = Session.getDefaultInstance(props, null);
    Message message = new MimeMessage(mailsession);
    message.setFrom(new InternetAddress(from));
    message.setRecipients(Message.RecipientType.TO,InternetAddress.parse(to, false));
    message.setSubject(subject);
    message.setHeader("X-Mailer", mailer);
    message.setSentDate(new Date());
    message.setText(msg_txt);
    BodyPart messageBodyPart = new MimeBodyPart();
    BodyPart messageBodyPart2 = new MimeBodyPart();
    Multipart multipart = new MimeMultipart(); // to add many part to your messge
    messageBodyPart = new MimeBodyPart();
    javax.activation.DataSource source = new javax.activation.FileDataSource("path of the file");
    messageBodyPart.setDataHandler(new DataHandler(source));
    messageBodyPart.setFileName("file_name");
    messageBodyPart2.setText("message"); // set the txt message
    multipart.addBodyPart(messageBodyPart);
    multipart.addBodyPart(messageBodyPart2);
    Transport.send(message);
    out.println("Message Sent");
    catch (Exception e)
    e.printStackTrace();
    if("Attachfiles".equalsIgnoreCase("attachfiles"))
    Attachfiles1=request.getParameter("fieldname1");
    Attachfiles2=request.getParameter("fieldname2");
    Attachfiles3=request.getParameter("fieldname3");
    %>
    <html>
    <body>
    <div class="frame">
         <form action="Composemail.jsp" method="post">
              <b>SelectPosition:</b> <select name="cars" >
    <option value="ABAP">ABAP
    <option value="saab">Saab
    <option value="fiat">Fiat
    <option value="audi">Audi
    </select><br><br>
    <table border="1" cellpadding="2" cellspacing="2">
    <tr><th>Name</th>
    <th>EmailId</th>
    <th>ContactNumber</th>
    <th>Position</th>
    </tr>
    <tr>
    <td>
    </td>
    </tr>
    </table><br>
    <b>SelectUser :</b><select name="cars">
    <option value="Administrator">Administrator
    <option value="saab">Saab
    <option value="fiat">Fiat
    <option value="audi">Audi
    </select>
    <br>
    <b>To :</b>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<input type="text" name="to" size="72"><br>
    <b>From :</b>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<input type="text" name="from" size="72"><br>
    <b>Subject :</b>&nbsp&nbsp&nbsp<input type="text" name="subject" size="72"><br>
    <%=Attachfiles1%><br><%=Attachfiles2%><br><%=Attachfiles3%><br><br>
    <b>Message:</b><br>
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<textarea rows="10" cols="50" name="message">
    </textarea> <br><br>
    <b>AttachedFile:</b>&nbsp<input type="file" name="fieldname1" value="filename" size="50"><br><br>
    <b>AttachedFile:</b>&nbsp<input type="file" name="fieldname2" value="filename" size="50"><br><br>
    <b>AttachedFile:</b>&nbsp<input type="file" name="fieldname3" value="filename" size="50"><br><br>
    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<input type="submit" name="attachfiles" value="Attachfiles">
    <center>
    <input type="submit" name="send" value="Send" >
    </center>
    </form>
    </div>
    </body>
    </html>

    Create a separate MimeBodyPart object for each attachment, rather than reusing
    the same one over and over.

  • How to send mail using jsp program

    am very new to jsp and doing my final year project. i need to send mails using my jsp program.can anyone say wht to do that is wht to include to send mails using jsp program. n also a sample code to send mail using jsp program.
    Thanx in advance

    Use below script.
    <%@ page import="java.util.*, javax.mail.*, javax.mail.internet.*" %>
    <%
    Properties props = new Properties();
    props.put("mail.smtp.host", "mailserver.com");
    Session s = Session.getInstance(props,null);
    InternetAddress from = new InternetAddress("[email protected]");
    InternetAddress to = new InternetAddress([email protected]");
    MimeMessage message = new MimeMessage(s);
    message.setFrom(from);
    message.addRecipient(Message.RecipientType.TO, to);
    message.setSubject("Your subject");
    message.setText("Your text");
    Transport.send(message);
    %>{code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Sending mail to multiple adress

    Hello friends,
    i have written java code for sending mail,its working fine for single mail address. if we include multiple mail address its giving ERROR:" Illegal route-addr in string" , so friends if there is any solution for this problem: please kindly mailto: "[email protected] " i hae included sendmail->code and setproperty->
    SENDMAIL
    public boolean sendMail(User userObj, Message message, String content){
         try{
    util util=new util();
         String arr[]=util.getTokens(userObj.email,",");
    InternetAddress inetarr[]=new InternetAddress[arr.length];
    for(int i=0;i<arr.length;i++){
         inetarr=new InternetAddress(arr[i].toString());
    message.setRecipients(Message.RecipientType.TO, inetarr);
    MimeMultipart multipart=new MimeMultipart();
    BodyPart msgBodyPart=new MimeBodyPart();
    msgBodyPart.setContent(content, "text/html");
    multipart.addBodyPart(msgBodyPart);
    message.setContent(multipart);
    message.setSentDate(new Date());
    Transport.send(message);
    return true;
    }catch(Exception e){
    e.printStackTrace();
    return false;
    }//End Of The Method
    GETPROPRITIES
    protected Properties getProperties(){
    Properties props = new Properties();
    props.put("mail.smtp.starttls.enable","true");
    props.put("mail.transport.protocol", "smtp");
    props.put("mail.smtp.host", adminObj.info.server[0]);
    props.put("mail.smtp.port",adminObj.info.server_port[0]+"");
    props.put("mail.debug","false");
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.quitwait", "false");
    props.put("mail.smtp.sendpartial", "true");
    return props;
    }//End Of The Method

    Hi,
    Thanks for your reply.I will avoid three don'ts in future postings.
    Acctual error message as follows
    javax.mail.internet.AddressException: Illegal route-addr in string ``saravana.07
    @gmail.com,[email protected]''
    at javax.mail.internet.InternetAddress.checkAddress(InternetAddress.java
    :883)
    at javax.mail.internet.InternetAddress.parse(InternetAddress.java:819)
    at javax.mail.internet.InternetAddress.parseHeader(InternetAddress.java:
    580)
    at javax.mail.internet.MimeMessage.getAddressHeader(MimeMessage.java:680
    at javax.mail.internet.MimeMessage.getFrom(MimeMessage.java:340)
    at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:897)
    at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:583)
    at javax.mail.Transport.send0(Transport.java:169)
    at javax.mail.Transport.send(Transport.java:98)
    at common.application.utilities.TenderMail.sendMail(TenderMail.java:483)
    at common.application.mail.send_user_mail.__BodhiReceive(send_user_mail.
    java:146)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
    java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at jdbs.BodhiServer.callStation(Unknown Source)
    at jdbs.BodhiSend.doSend(Unknown Source)
    at common.application.mail.sendmail.__BodhiReceive(sendmail.java:361)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
    java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at JumpForwarder1.callStation(JumpForwarder1.java:863)
    at JumpForwarder1.processRequest(JumpForwarder1.java:613)
    at JumpForwarder1.authenticateUserAndExecute(JumpForwarder1.java:254)
    at JumpForwarder1.doPost(JumpForwarder1.java:132)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
    icationFilterChain.java:284)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
    ilterChain.java:204)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
    alve.java:257)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
    eContext.java:151)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
    a:567)
    at org.apache.catalina.core.StandardContextValve.invokeInternal(Standard
    ContextValve.java:245)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
    alve.java:199)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
    eContext.java:151)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
    torBase.java:509)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
    eContext.java:149)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
    a:567)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
    ava:184)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
    eContext.java:151)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
    ava:164)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
    eContext.java:149)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
    a:567)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
    ve.java:156)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
    eContext.java:151)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
    a:567)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:20
    6)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
    :833)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
    ssConnection(Http11Protocol.java:732)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java
    :619)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
    ool.java:688)
    at java.lang.Thread.run(Thread.java:534)

  • Sending mail to yahoo using javamail

    hello,
    i have a javamail code which able to send mail within my domain (mailserver ) .
    but when i try to send mail to any yahoo id then i get following error :--
    javax.mail.SendFailedException: Invalid Addresses;
    please, anyone help me ; what should i do modification in my existing code for sending mail to yahoomail account.
    the code which is working properly for my doamin is:--
    import java.util.*;
    import java.io.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.activation.*;
    public class SendMailUsage {
    public static void main(String[] args) {
    // SUBSTITUTE YOUR EMAIL ADDRESSES HERE!!!
    String to = "[email protected]";
    String from = "[email protected]";
    // SUBSTITUTE YOUR ISP'S MAIL SERVER HERE!!!
    String host = "172.13.2.48";
    // Create properties for the Session
    Properties props = new Properties();
    // If using static Transport.send(),
    // need to specify the mail server here
    props.put("mail.smtp.host", host);
    // To see what is going on behind the scene
    props.put("mail.debug", "false");
    // Get a session
    Session session = Session.getInstance(props);
    try {
    // Get a Transport object to send e-mail
    Transport bus = session.getTransport("smtp");
    bus.connect();
    Message msg = new MimeMessage(session);
    msg.setFrom(new InternetAddress(from));
    InternetAddress[] address = {new InternetAddress(to)};
    msg.setRecipients(Message.RecipientType.TO, address);
    msg.setSubject("Test E-Mail through mojax developers");
    msg.setSentDate(new Date());
    // Set message content and send
    setTextContent(msg);
    msg.saveChanges();
    bus.sendMessage(msg, address);
    bus.close();
    catch (MessagingException mex) {
    // Prints all nested (chained) exceptions as well
    mex.printStackTrace();
    // How to access nested exceptions
    while (mex.getNextException() != null) {
    // Get next exception in chain
    Exception ex = mex.getNextException();
    ex.printStackTrace();
    if (!(ex instanceof MessagingException)) break;
    else mex = (MessagingException)ex;
    // A simple, single-part text/plain e-mail.
    public static void setTextContent(Message msg) throws MessagingException {
    // Set message content
    String mytxt = "this mail is generated by java";
    msg.setText(mytxt);
    // Alternate form
    msg.setContent(mytxt, "text/plain");
    } //End of class

    Turn on session debugging to get the protocol trace. Your mail server
    is probably saying more about why the send failed than what you've
    included here.
    Then read the FAQ for likely problems.

  • Sending mails with attachments using oracle 8i

    Hi,
    Could anybody please send a sample code for sending mails
    with attachments using oracle 8i.
    Thanks in advance

    For oracle8i there is an example package from OTN:
    http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/Utl_Smtp_Sample.html
    You have to re-write the package a bit to work it with BLOBs instead of RAW attachments, but that should be no problem
    Hop this helps,
    Michiel

  • Need help with mail sending mails..

    Can anybody help me with a code that works perfectly for sending mails.. since i used many codes which are not working, so please help me with the code to send mails please or else with an example.

    Hi kirupa_sankar,
    To send mails to others you have to use javax.mail.jar file and sample code is
    import javax.mail.*;
    import javax.mail.internet.*; // important
    import javax.mail.event.*; // important
    import java.net.*;
    import java.util.*;
    public class Mail {
    Properties props;
    Session session1;
    Message message;
    boolean flag=false;
    public boolean sendMail()
    props=new Properties();
    props.put("mail.smtp.host","mail.website.com"); // 'localhost' for testing
    session1 = Session.getDefaultInstance(props,null);
    String from= "[email protected]" ;
    String subject = "testing mail(subjective matter)";
    message =new MimeMessage(session1);
    message.setFrom(new InternetAddress(from));
    message.setRecipients(Message.RecipientType.TO,InternetAddress.parse("toaddress",false));
    message.setSubject(subject);
    message.setContent("content of the message");
    Transport.send(message);
    return true;
    try this one you will get success....

  • Workflow Step 'In Process'- Send mail with PDF attachment

    Hi,
    have to send mail with PDF attachment.
    I have written a function module with following steps,
    1. Convert SPOOL number to PDF using Function Module 'CONVERT_OTFSPOOLJOB_2_PDF'.
    2. Send mail with PDF attachment using Function Module 'SO_DOCUMENT_SEND_API1'.
    The Function Module is giving required output when tested and called in the report(Background Job).
    When I call this Function Module from Method-> Workflow Task the Workflow steps status is 'In Process' and not ending.
    Could you please help me on this??

    Hi shafath,
    When you try to send mail,  You need to call the function FP_JOB_OPEN before calling the function module to generate the pdf. ( /1B****)  . Is it missing in your code?

Maybe you are looking for