Problem with EXCEL format while sending a mail with excel attachment

Hi,
I'm trying to send a report through mail as an excel attchment. But though I get all the details in the attachmnet format in excel is not proper. It's in a very hapazard way. I tried putting control break statements after each record then also though there is slight betterment it's not ok. If I send the same thing as a pdf attachment it's perfect. May I know what else i need to do for excel.....? I tried compressing and then sending no luck......
I'm in version 4.6c.....
Thanks in advance....

Hi,
Just check out this..
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.
  CONCATENATE 'EBELN' 'EBELP' 'AEDAT' 'MATNR'
         INTO it_attach SEPARATED BY space.
  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 space.
    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 = 'This mail is scheduled automatically and excel file is
                attached for your reference'.
  APPEND it_message.
endform.                    " POPULATE_EMAIL_MESSAGE_BODY
Regards,
Sriram.
PS: Reward Points if it is useful.

Similar Messages

  • Problem in excel format while sending mail with excel attachment.

    Hi Gurus ,
    I am sending a email with Excel attachment using FM SO_DOCUMENT_SEND_API1 or SO_NEW_DOCUMENT_ATT_SEND_API1.
    I am able to send a mail with excel attachment with a piece of code which I got from SDN itself.
    But the problem is when I am trying to open the attachment, <b>A pop up comes which says that it is not in recognizable format. Would you like to open it?
    and several other lines of caution.</b>
    When i choose to open it, i get the correct data in one excel sheet. Certain vertical lines of the excel sheet is missing. <b>But no data is missing. </b>
    I am attaching the code below. Can any one please tell me where is the problem in this code ?
    Thanx in advance
    types: begin of t_mara,
    matnr type mara-matnr,
    matkl type mara-matkl,
    mtart type mara-mtart,
    meins type mara-meins,
    end of t_mara.
    data: gt_mara type table of t_mara,
    wa_mara like line of gt_mara,
    it_packing_list type table of SOPCKLSTI1,
    wa_packing_list like line of it_packing_list,
    it_receivers type table of SOMLRECI1,
    wa_receivers like line of it_receivers,
    it_mailbody type table of SOLISTI1,
    wa_mailbody like line of it_mailbody,
    it_attachment type table of SOLISTI1,
    wa_attachment like line of it_attachment.
    data: la_doc type SODOCCHGI1.
    constants:
    con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
    con_cret type c value cl_abap_char_utilities=>CR_LF.
    * get material
    select matnr matkl mtart meins
    into table gt_mara
    from mara
    up to 25 rows.
    * Populate the subject/generic message attributes
    la_doc-obj_langu = sy-langu.
    la_doc-obj_descr = 'Material Details' . "Mail Header
    la_doc-sensitivty = 'F'.
    la_doc-doc_size = 1.
    * Add the recipients email address
    CLEAR wa_receivers.
    REFRESH it_receivers.
    wa_receivers-receiver = 'PCSDEVL'.
    wa_receivers-rec_type = 'U'.
    wa_receivers-com_type = 'INT'.
    wa_receivers-notif_del = 'X'.
    wa_receivers-notif_ndel = 'X'.
    APPEND wa_receivers to it_receivers.
    * Mail Body
    CLEAR wa_mailbody.
    REFRESH it_mailbody.
    wa_mailbody-line = 'Please find the attachment'.
    APPEND wa_mailbody to it_mailbody.
    * Mail attachmwnt
    CLEAR wa_attachment.
    REFRESH it_attachment.
    CONCATENATE 'MATNR' 'MATKL' 'MTART' 'MEINS'
    INTO wa_attachment SEPARATED BY con_tab.
    CONCATENATE con_cret wa_attachment INTO wa_attachment.
    APPEND wa_attachment to it_attachment.
    LOOP AT gt_mara INTO wa_mara.
    CONCATENATE wa_mara-matnr wa_mara-matkl
    wa_mara-mtart wa_mara-meins
    INTO wa_attachment SEPARATED BY con_tab.
    CONCATENATE con_cret wa_attachment INTO wa_attachment.
    APPEND wa_attachment to it_attachment.
    ENDLOOP.
    * Describe the body of the message
    CLEAR wa_packing_list.
    REFRESH it_packing_list.
    wa_packing_list-transf_bin = space.
    wa_packing_list-head_start = 1.
    wa_packing_list-head_num = 0.
    wa_packing_list-body_start = 1.
    wa_packing_list-body_num = 1.
    wa_packing_list-doc_type = 'RAW'.
    APPEND wa_packing_list to it_packing_list.
    * Create attachment notification
    wa_packing_list-transf_bin = 'X'.
    wa_packing_list-head_start = 1.
    wa_packing_list-head_num = 1.
    wa_packing_list-body_start = 1.
    DESCRIBE TABLE it_attachment LINES wa_packing_list-body_num.
    wa_packing_list-doc_type = 'XLS'. " To word attachment change this as 'DOC'
    wa_packing_list-obj_descr = ' '.
    concatenate wa_packing_list-doc_type 'file' into wa_packing_list-OBJ_DESCR
    separated by space.
    wa_packing_list-doc_size = wa_packing_list-body_num * 255.
    APPEND wa_packing_list to it_packing_list.
    CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
    EXPORTING
    document_data = la_doc
    PUT_IN_OUTBOX = 'X'
    * SENDER_ADDRESS = SY-UNAME
    * SENDER_ADDRESS_TYPE = 'B'
    COMMIT_WORK = 'X'
    * IMPORTING
    * SENT_TO_ALL =
    * NEW_OBJECT_ID =
    * SENDER_ID =
    tables
    packing_list = it_packing_list
    * OBJECT_HEADER =
    CONTENTS_BIN = it_attachment
    CONTENTS_TXT = it_mailbody
    * CONTENTS_HEX =
    * OBJECT_PARA =
    * OBJECT_PARB =
    receivers = it_receivers
    EXCEPTIONS
    TOO_MANY_RECEIVERS = 1
    DOCUMENT_NOT_SENT = 2
    DOCUMENT_TYPE_NOT_EXIST = 3
    OPERATION_NO_AUTHORIZATION = 4
    PARAMETER_ERROR = 5
    X_ERROR = 6
    ENQUEUE_ERROR = 7
    OTHERS = 8
    IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.

    REPORT  Zex5 LINE-SIZE 255 LINE-COUNT 255 .
    class CL_ABAP_CHAR_UTILITIES definition load. "-->
    TABLES : vbap.
    SELECT-OPTIONS: s_vbeln FOR vbap-vbeln.
    DATA : BEGIN OF itab OCCURS 1,
           vbeln LIKE vbap-vbeln,
           posnr LIKE vbap-posnr,
           matnr LIKE vbap-matnr,
           END OF itab.
    parameters : p_email like somlreci1-receiver
    DATA: tlines type i.
    DATA: itmessage   LIKE solisti1 OCCURS 1 WITH HEADER LINE. "Ok
    DATA: itattach    LIKE solisti1 OCCURS 2 WITH HEADER LINE. "Ok
    DATA: itpacklist  LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE.
    DATA: itreclist   LIKE somlreci1 OCCURS 5 WITH HEADER LINE.
    data: itattachment like solisti1 OCCURS 2 WITH HEADER LINE.
    start-of-selection.
      SELECT vbeln posnr matnr
             FROM vbap
             INTO TABLE itab
             WHERE vbeln IN s_vbeln.
    **Make the internal table data to be compatible in excel format .
      PERFORM BUILD_XLS_FORMAT.
    **Populate message of body text.
      clear itmessage.
      refresh itmessage.
      itmessage = 'Please find attached Excel file'.
      append itmessage.
      PERFORM send_mail_as_xls_attachment tables itmessage
                                                 itattach
             using p_email 'Excel Attachment' 'TXT'    " 'XLS'
              using p_email 'TEXT Attachment' 'TXT'    " 'XLS'
                            'TestFileName'
                            'SalesOrders' .
    *&      Form  BUILD_XLS_FORMAT
          text
    -->  p1        text
    <--  p2        text
    form BUILD_XLS_FORMAT.
    previosuly we were using for unicode ..now replaced
    **Declare constants for the spacing .
    *Constants : con1 type x value '0D',
               con2 type x value '09'.
      Constants : con1 type c
            value CL_ABAP_CHAR_UTILITIES=>CR_LF,
            con2 type c
            value CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    **For the Header descriptions.
      Concatenate 'SalesORdNo'
                  'Item'
                  'Materialno' into itattach separated by con2.
      Concatenate con1 itattach into itattach.
      Append itattach.
    **Now align the items in the itab as above .
      Loop at Itab.
        concatenate itab-vbeln
                    itab-posnr
                    itab-matnr into itattach separated by con2.
        concatenate con1 itattach into itattach .
        Append itattach.
      endloop.
    endform.                    " BUILD_XLS_FORMAT
    *&      Form  send_mail_as_xls_attachment
          text
         -->P_ITMESSAGE  text
         -->P_ITATTACH  text
         -->P_P_EMAIL  text
         -->P_0116   text
         -->P_0117   text
         -->P_0118   text
         -->P_0119   text
    form send_mail_as_xls_attachment tables   p_itmessage
                                              p_itattach
                                     using    p_email
                                              p_mtitle
                                              p_format
                                              p_filename
                                              p_attdescription.
      Data : xdocdata like sodocchgi1,
             xcnt type i.
    *Fill the document data.
      xdocdata-doc_size = 1.
    *Populate the subject/generic message attributes.
      xdocdata-obj_name  = 'SAPRPT'.
      xdocdata-obj_langu = sy-langu.
      xdocdata-obj_descr = p_mtitle.
    *Fill the document data and fetch size of attachment.
      clear xdocdata.
      read table itattach index xcnt.
      xdocdata-doc_size = ( xcnt - 1 ) * 255 + strlen( itattach ).
    xdocdata-doc_size =  ( xcnt - 1 ) * 255.
      xdocdata-obj_name  = 'SAPRPT'.
      xdocdata-obj_langu = sy-langu.
      xdocdata-obj_descr = p_mtitle.
      clear itattachment. refresh itattachment.
         itattachment[] = p_itattach[].
    *Describe the body of the message.
      clear itpacklist. refresh itpacklist.
      itpacklist-transf_bin = 'X'.
      itpacklist-head_start = '1'.
      itpacklist-head_num = '0'.
      itpacklist-body_start = '1'.
      describe table itattachment lines itpacklist-body_num .
      itpacklist-doc_type = 'TXT'.
    itpacklist-doc_type = 'XLS'.
      append itpacklist.
    *Create attachment notification.
      itpacklist-transf_bin = 'X'.
      itpacklist-head_start = '1'.
      itpacklist-head_num = '1'.
      itpacklist-body_start = '1'.
      describe table itattachment lines itpacklist-body_num .
      itpacklist-doc_type = p_format.
      itpacklist-obj_name = p_filename.
      itpacklist-obj_descr = p_attdescription.
      itpacklist-doc_size = itpacklist-body_num * 255 .
      append itpacklist.
    *FIll the receivers list.
      Clear itreclist. refresh itreclist.
      itreclist-receiver = p_email.
      itreclist-rec_type = 'U'.
      itreclist-com_type = 'INT'.
      itreclist-notif_del = 'X'.
      itreclist-notif_ndel = 'X'.
    *itreclist-notif_read = 'X'.
      append itreclist.
    *CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
    EXPORTING
      document_data                    = xdocdata
      PUT_IN_OUTBOX                    = 'X'
      commit_work    = 'X'
      SENDER_ADDRESS                   = SY-UNAME
    tables
       packing_list                    = itpacklist
       CONTENTS_BIN                    = itattachment
       CONTENTS_TXT                    = itmessage
       receivers                       = itreclist
    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.
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = xdocdata
          PUT_IN_OUTBOX              = 'X'
        TABLES
          packing_list               = itpacklist
          CONTENTS_BIN               = itattachment
          CONTENTS_TXT               = itmessage
          receivers                  = itreclist
        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.
    endform.                    " send_mail_as_xls_attachment
    Just execute the above code and let me know.
    What is the sap version u r using .
    Vijay

  • Problem while sending a mail with smtp and ssl

    Hi all,
    I am new to java mail . I have downloaded one java program to send the mail. I have configured smt and port address.And my System firewall is also in off mode
    Still i am unable to send the mail
    The following code is my program import java.util.Properties;
    import javax.mail.Authenticator;
    import javax.mail.Message;
    import javax.mail.MessagingException;
    import javax.mail.PasswordAuthentication;
    import javax.mail.Session;
    import javax.mail.Transport;
    import javax.mail.URLName;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeMessage;
    import com.sun.mail.smtp.SMTPSSLTransport;
      To use this program, change values for the following three constants,
        SMTP_HOST_NAME -- Has your SMTP Host Name
        SMTP_AUTH_USER -- Has your SMTP Authentication UserName
        SMTP_AUTH_PWD  -- Has your SMTP Authentication Password
      Next change values for fields
      emailMsgTxt  -- Message Text for the Email
      emailSubjectTxt  -- Subject for email
      emailFromAddress -- Email Address whose name will appears as "from" address
      Next change value for "emailList".
      This String array has List of all Email Addresses to Email Email needs to be sent to.
      Next to run the program, execute it as follows,
      SendMailUsingAuthentication authProg = new SendMailUsingAuthentication();
    public class SendMailUsingAuthentication
    //private static final String SMTP_HOST_NAME = "smtp.mail.yahoo.com";
         private static final String SMTP_HOST_NAME = "smtp.gmail.com";
      private static final String SMTP_AUTH_USER = "admijn.ramd";
      private static final String SMTP_AUTH_PWD  = "hairamu";
      private static final int SMTP_PORT  = 465;
      private static final String emailMsgTxt      = "Online Order Confirmation Message. Also include the Tracking Number.";
      private static final String emailSubjectTxt  = "Order Confirmation Subject";
      private static final String emailFromAddress = "[email protected]";
      // Add List of Email address to who email needs to be sent to
      private static final String[] emailList = {"[email protected]", "[email protected]"};
      public static void main(String args[]) throws Exception
        SendMailUsingAuthentication smtpMailSender = new SendMailUsingAuthentication();
        smtpMailSender.postMail( emailList, emailSubjectTxt, emailMsgTxt, emailFromAddress);
      public void postMail( String recipients[ ], String subject,
                                String message , String from)
           try{
        boolean debug = false;
         //Set the host smtp address
    //  Set the host smtp address
         Properties props = new Properties();
         props.put("mail.transport.protocol", "smtp");
         props.put("mail.smtp.port", SMTP_PORT);
         props.put("mail.smtp.starttls.enable","true");
         props.put("mail.smtp.host", SMTP_HOST_NAME);
         props.put("mail.smtp.auth", "true");
          props.put("mail.smtp.socketFactory.port", SMTP_PORT);
         props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
          props.put("mail.smtp.socketFactory.fallback", "false");
          SecurityManager security = System.getSecurityManager();
         Authenticator auth = new SMTPAuthenticator();
         Session session = Session.getDefaultInstance(props, auth);
         session.setDebug(debug);
         // create a message
         Message msg = new MimeMessage(session);
         // set the from and to address
         InternetAddress addressFrom = new InternetAddress(from);
         msg.setFrom(addressFrom);
         InternetAddress[] addressTo = new InternetAddress[recipients.length];
         for (int i = 0; i < recipients.length; i++) {
              addressTo[i] = new InternetAddress(recipients);
         msg.setRecipients(Message.RecipientType.TO, addressTo);
         // Setting the Subject and Content Type
         msg.setText(message);
         msg.setSubject(subject);
         msg.setContent(message, "text/plain");
         Transport.send(msg);
         }catch (MessagingException e) {
              // TODO: handle exception
              e.printStackTrace();
    * SimpleAuthenticator is used to do simple authentication
    * when the SMTP server requires it.
    private class SMTPAuthenticator extends javax.mail.Authenticator
    public PasswordAuthentication getPasswordAuthentication()
         try{
    String username = SMTP_AUTH_USER;
    String password = SMTP_AUTH_PWD;
    System.out.println("username "+ username+" Password"+password);
    return new PasswordAuthentication(username, password);
         }catch (Exception e) {
         return null;
    And i am getting the following exceptions
    javax.mail.MessagingException: Exception reading response;
      nested exception is:
         javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
         at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1611)
         at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1369)
         at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:412)
         at javax.mail.Service.connect(Service.java:310)
         at javax.mail.Service.connect(Service.java:169)
         at javax.mail.Service.connect(Service.java:118)
         at javax.mail.Transport.send0(Transport.java:188)
         at javax.mail.Transport.send(Transport.java:118)
         at com.FutureSoft.org.SendingMail.SendMailUsingAuthentication.postMail(SendMailUsingAuthentication.java:123)
         at com.FutureSoft.org.SendingMail.SendMailUsingAuthentication.main(SendMailUsingAuthentication.java:70)
    Caused by: javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
         at com.sun.net.ssl.internal.ssl.InputRecord.handleUnknownRecord(Unknown Source)
         at com.sun.net.ssl.internal.ssl.InputRecord.read(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:110)
         at java.io.BufferedInputStream.fill(Unknown Source)
         at java.io.BufferedInputStream.read(Unknown Source)
         at com.sun.mail.util.LineInputStream.readLine(LineInputStream.java:88)
         at com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1589)
         ... 9 more                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    hi neuro11
    the following code is for sending mail its is working fine in my system, just change the
    SMTP_AUTH_USER = "tina.numi"; with u r email user name
    SMTP_AUTH_PWD = "abdcde"; u r gmail password
    emailFromAddress = "[email protected]"; ur gmail addres
    emailList = {"[email protected]"}; receipient list .
    and u must sure that u r internet is on and firewall should be off . some times firewall restricts you to communicate with gmail port number
    Please make u r firewall off and source code is
    package com.FutureSoft.org.SendingMail;
    Some SMTP servers require a username and password authentication before you
    can use their Server for Sending mail. This is most common with couple
    of ISP's who provide SMTP Address to Send Mail.
    This Program gives any example on how to do SMTP Authentication
    (User and Password verification)
    This is a free source code and is provided as it is without any warranties and
    it can be used in any your code for free.
    Author : Sudhir Ancha
    import java.util.Properties;
    import javax.mail.Authenticator;
    import javax.mail.Message;
    import javax.mail.MessagingException;
    import javax.mail.PasswordAuthentication;
    import javax.mail.Session;
    import javax.mail.Transport;
    import javax.mail.URLName;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeMessage;
    import com.sun.mail.smtp.SMTPSSLTransport;
      To use this program, change values for the following three constants,
        SMTP_HOST_NAME -- Has your SMTP Host Name
        SMTP_AUTH_USER -- Has your SMTP Authentication UserName
        SMTP_AUTH_PWD  -- Has your SMTP Authentication Password
      Next change values for fields
      emailMsgTxt  -- Message Text for the Email
      emailSubjectTxt  -- Subject for email
      emailFromAddress -- Email Address whose name will appears as "from" address
      Next change value for "emailList".
      This String array has List of all Email Addresses to Email Email needs to be sent to.
      Next to run the program, execute it as follows,
      SendMailUsingAuthentication authProg = new SendMailUsingAuthentication();
    public class SendMailUsingAuthentication
    //private static final String SMTP_HOST_NAME = "smtp.mail.yahoo.com";
         private static final String SMTP_HOST_NAME = "smtp.gmail.com";
      private static final String SMTP_AUTH_USER = "tina.numi";// gmail username
      private static final String SMTP_AUTH_PWD  = "abdcde";// gmail password
      private static final int SMTP_PORT  = 465;
      private static final String emailMsgTxt      = "Online Order Confirmation Message. Also include the Tracking Number.";
      private static final String emailSubjectTxt  = "Order Confirmation Subject";
      private static final String emailFromAddress = "[email protected]";// gmail id
      // Add List of Email address to who email needs to be sent to
      private static final String[] emailList = {"[email protected]"};
      public static void main(String args[]) throws Exception
        SendMailUsingAuthentication smtpMailSender = new SendMailUsingAuthentication();
        smtpMailSender.postMail( emailList, emailSubjectTxt, emailMsgTxt, emailFromAddress);
      public void postMail( String recipients[ ], String subject,
                                String message , String from)
           try{
        boolean debug = false;
         //Set the host smtp address
    //  Set the host smtp address
         Properties props = new Properties();
         props.put("mail.transport.protocol", "smtp");
         props.put("mail.smtp.port", SMTP_PORT);
         props.put("mail.smtp.starttls.enable","true");
         props.put("mail.smtp.host", SMTP_HOST_NAME);
         props.put("mail.smtp.auth", "true");
          props.put("mail.smtp.socketFactory.port", SMTP_PORT);
         props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
          props.put("mail.smtp.socketFactory.fallback", "false");
          SecurityManager security = System.getSecurityManager();
         Authenticator auth = new SMTPAuthenticator();
         Session session = Session.getInstance(props, auth);
         session.setDebug(debug);
         // create a message
         Message msg = new MimeMessage(session);
         // set the from and to address
         InternetAddress addressFrom = new InternetAddress(from);
         msg.setFrom(addressFrom);
         InternetAddress[] addressTo = new InternetAddress[recipients.length];
         for (int i = 0; i < recipients.length; i++) {
              addressTo[i] = new InternetAddress(recipients);
         msg.setRecipients(Message.RecipientType.TO, addressTo);
         // Setting the Subject and Content Type
         msg.setText(message);
         msg.setSubject(subject);
         msg.setContent(message, "text/plain");
         Transport t = session.getTransport("smtps");
         try {
              t.connect(SMTP_HOST_NAME, SMTP_AUTH_USER, SMTP_AUTH_PWD);
              t.sendMessage(msg, msg.getAllRecipients());
         catch(Exception e){}
         finally
              t.close();
         }catch (MessagingException e) {
              // TODO: handle exception
              e.printStackTrace();
    * SimpleAuthenticator is used to do simple authentication
    * when the SMTP server requires it.
    private class SMTPAuthenticator extends javax.mail.Authenticator
    public PasswordAuthentication getPasswordAuthentication()
         try{
    String username = SMTP_AUTH_USER;
    String password = SMTP_AUTH_PWD;
    System.out.println("username "+ username+" Password"+password);
    return new PasswordAuthentication(username, password);
         }catch (Exception e) {
         return null;
    try this . all the best

  • Error while sending a mail with pdf attachment

    Hai
    I am sending mail with an attachment of PDF document. While sending I am getting
    javax.activation.UnsupportedDataTypeException: application/pdf
    This is my code
    public static void setByteArrayAsAttachment(Message msg, byte[] attach)
    throws MessagingException {
    MimeBodyPart p1 = new MimeBodyPart();
    ByteArrayDataSource byteStr = new ByteArrayDataSource(attach,"application/pdf");
    p1.setContent(byteStr,"application/pdf");
    Multipart mp = new MimeMultipart();
    mp.addBodyPart(p1);
    msg.setContent(mp);
    Can one one help me on this...
    Thanks
    Jithesh PM

    Change
    p1.setContent(byteStr,"application/pdf");
    to
    p1.setDataHandler(new DataHandler(byteStr));

  • Excel 2007 Problems while sending E-Mail with Excel Attachment

    Hello all,
    i wrote a small WD application for uploading a file and sending this file
    vie e-mail to some recipients.
    I'm using class "cl_document_bcs". No problem with ".doc", ".pdf", also no problem
    with ".xls" files generated by old Excel version. But when generating an .xls document with
    Excel 2007, the attached file is not readable (just non usable signs).
    For attaching the .xls file i use:
      TRY.
          lr_attachment =  cl_document_bcs=>create_document(
              i_type        = lv_filetype " --> 'XLS'
              i_subject     = 'excel document'
              i_hex         = lt_file_solix
        CATCH cx_document_bcs .
      ENDTRY.
    Are there any restrictions regarding Excel 2007?
    The data element of i_type is just char3, so XLSX
    wouldn't be possible.

    hello Christopher Linke ,
    if you Programatically generation a excel file and you have 2007 version you can use OLE automation to save file as .xls i.e. a 2003 work book ..
    if you have a excel file ready and you just want to send it across the you will have to convert the xlsx to xls and then send it you can do this as well using OLE automation
    (in 2007 in SAVE AS option you can save it excel 97 2003 workbook)
    Edited by: Anup Deshmukh on Mar 3, 2010 3:38 PM

  • Send a mail with change history while changing the Routing (T-Code CA02),

    Hi All,
    I need to send a mail with change history while changing the Routing (T-Code CA02), Please let me know how can implement this scenario.
    I am trying to find out any workflow is there for the same but we have workflow for Routing creating and Display, we donu2019t have workflow for change.
    Please suggest meu2026u2026u2026u2026
    Thanks,
    Amjad.

    Hi All,
    I need to send a mail with change history while changing the Routing (T-Code CA02), Please let me know how can implement this scenario.
    I am trying to find out any workflow is there for the same but we have workflow for Routing creating and Display, we donu2019t have workflow for change.
    Please suggest meu2026u2026u2026u2026
    Thanks,
    Amjad.

  • TS3276 Hey. I have problems to send e-mail with Mail. The problems is I need to un active ssl ,... but when I do this,... automatically,. its active again????. Whta can i do

    Hey. I have problems to send e-mail with Mail. The problems is I need to un active ssl ,... but when I do this,... automatically,. its active again????. Whta can i do

    Try posting this in the 10.7 Mail forum. You'll get more help there.
    DALE

  • Send External mail with Attchment from SAP

    Hi All,
    OUR REQUIREMENT: We need to send EXTERNAL MAIL with ATTACHMENT(Excel) form SAP .
    We have developed a function module which converts the internal table data into Excel Format and sends it as an attachment to External Mail.
    ISSUE : But our issue is we are unable to open that document using GOOGLE DOCS Could any one help me how to do this.
    it was thriughing error like
    Error log is .
    ''Sorry, we are unable to generate a view of the document at this time. Please try again later.
    You can also try to download the original document by clicking here. Alternatively, you can view the plain HTML (automatically redirecting).
    Regards
    Venkat .
    Edited by: venkata pradeep on Mar 5, 2012 10:26 AM
    Edited by: venkata pradeep on Mar 5, 2012 10:28 AM

    Is the excel file recognized by MS Excel? If not, then issue is you have wrongly converted your attachment and/or your FM to create an excel file was wrongly coded or you have passed it wrongly to your mail code.
    If you consider an OOP approach in sending external mail, refer to this link:
    http://wiki.sdn.sap.com/wiki/display/Snippets/SendingmailwithattachmentusingObjectOriented+Approach

  • Blind copy while sending a mail...

    Hi Friends,
    How to set a recipient under the blind copy recipient list (BCC) while sending a mail using the function module SO_DOCUMENT_SEND_API1. I have checked the flag <b>blind_copy</b> but not seeing that recipient under the bcc list. Some body please help in this.
    Thanx in advance.
    Ram

    See the example program :
    TABLES: SOLI.
       Data Declarations
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    PARAMETERS: SAPID     RADIOBUTTON GROUP ADDR,
                EMAIL_ID  RADIOBUTTON GROUP ADDR.
    SELECTION-SCREEN END OF BLOCK B1.
    SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
    SELECT-OPTIONS: ID  FOR SOLI-LINE NO INTERVALS.
    SELECT-OPTIONS: CC  FOR SOLI-LINE NO INTERVALS.
    SELECT-OPTIONS: BCC FOR SOLI-LINE NO INTERVALS.
    *PARAMETERS:     SENDER LIKE SOUD-USRNAM.
    SELECTION-SCREEN END OF BLOCK B2.
    SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-009.
    PARAMETERS: SUB_LINE(60) TYPE C.
    SELECTION-SCREEN END OF BLOCK B3.
    SELECTION-SCREEN BEGIN OF BLOCK B4 WITH FRAME TITLE TEXT-008.
    SELECT-OPTIONS:  TEXT1 FOR SOLI-LINE NO INTERVALS.
    SELECTION-SCREEN END OF BLOCK B4.
    SELECTION-SCREEN BEGIN OF BLOCK B5 WITH FRAME TITLE TEXT-009.
    SELECTION-SCREEN BEGIN OF LINE.
    parameters: P_ATTACH as checkbox.
    selection-screen comment 3(30) text-010.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK B5.
    DATA: MAIL_CONTENT LIKE SOLI OCCURS 0 WITH HEADER LINE,
          SUBJECT_LINE LIKE SOOD1-OBJDES.
       Start of program processing
    START-OF-SELECTION.
    Get the Body of the Message from the selection screen or from
    calling program
      LOOP AT TEXT1.
        MOVE   TEXT1-LOW TO MAIL_CONTENT-LINE.
        APPEND MAIL_CONTENT.
      ENDLOOP.
    Subject of the Message
      MOVE  SUB_LINE TO SUBJECT_LINE.
    call a routine to send the workflow message
      PERFORM SEND_EMAIL
              TABLES MAIL_CONTENT
              USING  SUBJECT_LINE.
    *&      Form  SEND_EMAIL
    Send Workflow message
    FORM SEND_EMAIL TABLES OBJCONT STRUCTURE MAIL_CONTENT
                    USING  TITLE   LIKE SOOD-OBJDES.
      DATA: RECEIVERS LIKE SOOS1 OCCURS 0 WITH HEADER LINE,
            TSOOD1 LIKE SOOD1,
            PACKING_LIST LIKE SOXPL OCCURS 0 WITH HEADER LINE,
            OBJCONT1 LIKE MAIL_CONTENT OCCURS 0 WITH HEADER LINE.
      DATA: BEGIN OF AT_HEADER OCCURS 1.
              INCLUDE STRUCTURE SOLI.
      DATA: END OF AT_HEADER.
      CLEAR: TSOOD1,
             RECEIVERS.
      REFRESH RECEIVERS.
      MOVE:  SY-LANGU       TO TSOOD1-OBJLA,
             'Email Notice' TO TSOOD1-OBJNAM,
             'C'            TO TSOOD1-OBJSNS,
             TITLE          TO TSOOD1-OBJDES.
           'SCHIAVONIR'   TO TSOOD1-OWNNAM.
    loop through each ID and move them to recipient table
      LOOP AT ID.
        TRANSLATE ID-LOW TO UPPER CASE.
        IF SAPID = 'X'.
          MOVE: SY-DATUM     TO RECEIVERS-RCDAT,
                SY-UZEIT     TO RECEIVERS-RCTIM,
                ' '          TO RECEIVERS-RECESC,
                 ID-LOW      TO RECEIVERS-RECNAM,
                'X'          TO RECEIVERS-SNDEX.
        ELSE.
          MOVE: SY-DATUM     TO RECEIVERS-RCDAT,
                SY-UZEIT     TO RECEIVERS-RCTIM,
                'U'          TO RECEIVERS-RECESC,
                'U-'         TO RECEIVERS-RECNAM,
                ID-LOW       TO RECEIVERS-RECEXTNAM.
        ENDIF.
        APPEND RECEIVERS.
        CLEAR RECEIVERS.
      ENDLOOP.
    loop through each CC and move them to recipient table
      LOOP AT CC.
        TRANSLATE CC-LOW TO UPPER CASE.
        IF SAPID = 'X'.
          MOVE: SY-DATUM     TO RECEIVERS-RCDAT,
                SY-UZEIT     TO RECEIVERS-RCTIM,
                ' '          TO RECEIVERS-RECESC,
                 CC-LOW      TO RECEIVERS-RECNAM,
                'X'          TO RECEIVERS-SNDEX,
                'X'          TO RECEIVERS-SNDCP.
        ELSE.
          MOVE: SY-DATUM     TO RECEIVERS-RCDAT,
                SY-UZEIT     TO RECEIVERS-RCTIM,
                'U'          TO RECEIVERS-RECESC,
                'U-'         TO RECEIVERS-RECNAM,
                CC-LOW       TO RECEIVERS-RECEXTNAM,
                'X'          TO RECEIVERS-SNDCP.
        ENDIF.
        APPEND RECEIVERS.
        CLEAR RECEIVERS.
      ENDLOOP.
    loop through each BCC and move them to recipient table
      LOOP AT BCC.
        TRANSLATE BCC-LOW TO UPPER CASE.
        IF SAPID = 'X'.
          MOVE: SY-DATUM     TO RECEIVERS-RCDAT,
                SY-UZEIT     TO RECEIVERS-RCTIM,
                ' '          TO RECEIVERS-RECESC,
                 BCC-LOW     TO RECEIVERS-RECNAM,
                'X'          TO RECEIVERS-SNDEX,
                'X'          TO RECEIVERS-SNDBC.
        ELSE.
          MOVE: SY-DATUM     TO RECEIVERS-RCDAT,
                SY-UZEIT     TO RECEIVERS-RCTIM,
                'U'          TO RECEIVERS-RECESC,
                'U-'         TO RECEIVERS-RECNAM,
                BCC-LOW      TO RECEIVERS-RECEXTNAM,
                'X'          TO RECEIVERS-SNDBC.
        ENDIF.
        APPEND RECEIVERS.
        CLEAR RECEIVERS.
      ENDLOOP.
      AT_HEADER = SY-DATUM.
      APPEND AT_HEADER.
      AT_HEADER = SY-UZEIT.
      APPEND AT_HEADER.
    IF SENDER EQ SPACE.
       SENDER = SY-UNAME.
    ENDIF.
      IF P_ATTACH EQ 'X'.
        PACKING_LIST-HEAD_START = 1.
        PACKING_LIST-HEAD_NUM   = 2.
        PACKING_LIST-BODY_START = 1.
        PACKING_LIST-BODY_NUM   = 9999.
        PACKING_LIST-FILE_EXT   = 'TXT'.
        APPEND PACKING_LIST.
        CLEAR  PACKING_LIST.
        APPEND LINES OF OBJCONT TO OBJCONT1.
        REFRESH OBJCONT.
      ENDIF.
      CALL FUNCTION 'SO_OBJECT_SEND'
           EXPORTING
                OBJECT_HD_CHANGE           = TSOOD1
                OBJECT_TYPE                = 'RAW'
           TABLES
                OBJCONT                    = OBJCONT
                RECEIVERS                  = RECEIVERS
                ATT_HEAD                   = AT_HEADER
                ATT_CONT                   = OBJCONT1
                PACKING_LIST               = PACKING_LIST
           EXCEPTIONS
                ACTIVE_USER_NOT_EXIST      = 1
                COMMUNICATION_FAILURE      = 2
                COMPONENT_NOT_AVAILABLE    = 3
                FOLDER_NOT_EXIST           = 4
                FOLDER_NO_AUTHORIZATION    = 5
                FORWARDER_NOT_EXIST        = 6
                NOTE_NOT_EXIST             = 7
                OBJECT_NOT_EXIST           = 8
                OBJECT_NOT_SENT            = 9
                OBJECT_NO_AUTHORIZATION    = 10
                OBJECT_TYPE_NOT_EXIST      = 11
                OPERATION_NO_AUTHORIZATION = 12
                OWNER_NOT_EXIST            = 13
                PARAMETER_ERROR            = 14
                SUBSTITUTE_NOT_ACTIVE      = 15
                SUBSTITUTE_NOT_DEFINED     = 16
                SYSTEM_FAILURE             = 17
                TOO_MUCH_RECEIVERS         = 18
                USER_NOT_EXIST             = 19
                X_ERROR                    = 20
                OTHERS                     = 21.
    ENDFORM.                               " SEND_EMAIL
    text elements
    BCC     Blind CC
    CC     Copy to
    EMAIL_ID     Email ID
    ID     ?...
    P_ATTACH     Send as Attachment?
    SAPID     SAP ID
    SUB_LINE     Subject
    TEXT1     Message

  • How to send a mail with rich text content like using outlook

    Hi All. I have a serious problem. When we send the mail from
    outlook express or yahoo, we can send the mail with the text appearing
    in the mail with bold font , with different colors, underlined etc.
    If i type this kind of text in any word processor and mail that content through java mail then the message should be received by the recepient with all that bold,color and underlines etc as it is. Can anybody please help me in this case ASAP.

    Go to this site and download the htmlArea Javascripts. Embedd them in your HTML and it will turn your normal HTML Text Area into Rich Text Area. Your real code will include all HTML tags. For example if you select some text and make it bold , the real HTML output will look like <B>YOUR TEXT </B>. So i guess your recipient should be able to receive HTML contents.
    http://www.interactivetools.com/products/htmlarea/

  • How to send a mail with HTML body from Oracle

    Hi Team,
    Can somebody guide me how to send a mail with HTML body from oracle.
    Here is the piece of code i am trying to send a mail.
    procedure SEND_MAIL is
    cursor c_1 is select * from table_name;
    l_mail_id varchar2(40);
    -- ls_mailhost VARCHAR2(64) := Mailhost;
    ls_from VARCHAR2(64) := ‘[email protected]
    ls_subject VARCHAR2(200);
    ls_to VARCHAR2(64);
    l_mail_conn UTL_SMTP.connection;
    ls_left_menu_name VARCHAR2(64);
    ll_emp_num number(8);
    begin
    for i in c_1 loop
    begin
    l_mail_conn := UTL_SMTP.OPEN_CONNECTION('IP');
    UTL_SMTP.HELO(l_mail_conn, 'IP');
    UTL_SMTP.MAIL(l_mail_conn, LS_FROM);
    UTL_SMTP.RCPT(L_mail_conn, LS_TO);
    UTL_SMTP.DATA(l_mail_conn,'From: ' ||ls_from || utl_tcp.crlf ||
    'To: ' ||ls_to || utl_tcp.crlf ||
    'Subject: ' ||ls_subject|| utl_tcp.crlf);
    UTL_SMTP.QUIT(l_mail_conn);
    exception
    when no_data_found then
    null;
    when others then
    RAISE_APPLICATION_ERROR(-20000, 'Failed to send mail due to the following error: ' || sqlerrm);
    end;
    end loop;
    end;
    Thnx

    Hi Nicolas!
    Have you tried to set "Output Format" for "RAW Text" to HTM in SCOT.
    If HTM is missing in your dropdown-list, you could check out table SXCONVERT2. Copy the line with category T/format TXT, and change the format from TXT to HTM. The existing function
    SX_OBJECT_CONVERT__T.TXT does not need to be changed. Now you should be able to choose HTM in SCOT. You will probably need som HTML-tags in your text to make it look good.
    Hope this helps!
    Regards
    Geir

  • Send E-mail with payment advice to several address

    Hi Experts
    In our company in USA we set a payment through ACH, for it we need to send a payment advice to the vendor after we run process in F110, that process is run properly but the problem is we need to send some mails to more than one receiver, and the option to input it is in vendor master data, but at the moment to send e-mail the system only send mail to first address, some one have idea can I do for send to several address???
    Thanks

    HI,
    I am assuming that you are using BTE 2040 or 2050 to achieve this. Instead of using the sample FM provided by SAP for this BTE, copy it to a Y/Z FM and then you can modify it accordingly.
    My suggestion would be to create a custom table for the email addresses and pick the additional email addresses from there in conjugation with the Vendor master.
    Regards

  • Payslip in PDF Format and send to mail

    Hi,
    I created one Payslip in SMARTFORMS,
    Now i want to convert into PDF Format and send as mail....
    How to do Pls help me...
    with regards
    suresh
    Edited by: rsnaidu on Jun 28, 2011 3:28 PM

    Please check this link...
    [http://help.sap.com/saphelp_nw04/helpdata/en/27/67443cc0063415e10000000a11405a/content.htm|http://help.sap.com/saphelp_nw04/helpdata/en/27/67443cc0063415e10000000a11405a/content.htm]
    -Muktar

  • How to send e-mail with an attachment from remote database server.???

    Hi All,
    I have tried the simple mail sending and with the attachment using UTL_SMTP. But the problem is , it is sending the mail with attachment of the file name i give, it takes and creates that file and sends as attachment not from the actual file location. I am trying to attach the file which i stored in remote database server.
    The following code I tried. But not worked for attachment
    DECLARE
       v_From       VARCHAR2(80) := '[email protected]';
       v_Recipient  VARCHAR2(80) := '[email protected]';
       v_Subject    VARCHAR2(80) := 'test subject';
       v_Mail_Host  VARCHAR2(30) := 'pop3.somedomain.com';
       v_Mail_Conn  utl_smtp.Connection;
       crlf         VARCHAR2(2)  := chr(13)||chr(10);
    BEGIN
      v_Mail_Conn := utl_smtp.Open_Connection(v_Mail_Host, 25);
      utl_smtp.Helo(v_Mail_Conn, v_Mail_Host);
      utl_smtp.Mail(v_Mail_Conn, v_From);
      utl_smtp.Rcpt(v_Mail_Conn, v_Recipient);
      utl_smtp.Data(v_Mail_Conn,
        'Date: '   || to_char(sysdate, 'Dy, DD Mon YYYY hh24:mi:ss') || crlf ||
        'From: '   || v_From || crlf ||
        'Subject: '|| v_Subject || crlf ||
        'To: '     || v_Recipient || crlf ||
        'MIME-Version: 1.0'|| crlf ||     -- Use MIME mail standard
        'Content-Type: multipart/mixed;'|| crlf ||
        ' boundary="-----SECBOUND"'|| crlf ||
        crlf ||
        '-------SECBOUND'|| crlf ||
        'Content-Type: text/html;'|| crlf ||
        'Content-Transfer_Encoding: 7bit'|| crlf ||
        crlf ||
        'some message text'|| crlf ||     -- Message body
        'more message text'|| crlf ||
        crlf ||
        '-------SECBOUND'|| crlf ||
        'Content-Type: text/html;'|| crlf ||
        ' name="Fund Authorization report"'|| crlf ||
        'Content-Transfer_Encoding: 8bit'|| crlf ||
        'Content-Disposition: attachment;'|| crlf ||
        ' filename="/usr/tmp/Test.html"'|| crlf ||
        crlf ||
        'HTML Attachment'|| crlf ||     -- Content of attachment
        crlf ||
        '-------SECBOUND--'               -- End MIME mail
      utl_smtp.Quit(v_mail_conn);
    EXCEPTION
      WHEN utl_smtp.Transient_Error OR utl_smtp.Permanent_Error then
        raise_application_error(-20000, 'Unable to send mail: '||sqlerrm);
    END;How can I attach a file which is stored in database server and send it in a mail.
    Please someone help me in this.
    Thanks,
    Alaka.

    Try this code
    Regards Salim.
    CREATE OR REPLACE TRIGGER EmailOnServerErr AFTER SERVERERROR ON DATABASE
    DECLARE
       mail_conn       UTL_SMTP.connection;
       crlf            VARCHAR2(2) := chr(13)||chr(10);
       msg             VARCHAR2(32760);
       sid_name        VARCHAR2(16);
       bdump_dest      VARCHAR2(128);
       smtp_relay      VARCHAR2(32) := 'MyMailRelay';
       recipient_address  VARCHAR2(64) := '[email protected]';
       sender_address     VARCHAR2(64) := '[email protected]';
       mail_port       NUMBER := 25;
       log_file_handle UTL_FILE.FILE_TYPE;
       log_file_dir    VARCHAR2(256) := 'ERR_LOG_DIR';
       log_file_name   VARCHAR2(256) := 'OracleErrors.log';
       maxlinesize     NUMBER := 32767;
       session_rec     sys.v_$session%ROWTYPE;
       audit_rec       sys.dba_audit_trail%ROWTYPE;
       auditing        BOOLEAN;
       LinesOfSQL      BINARY_INTEGER;
       offending_sql   DBMS_STANDARD.ora_name_list_t;
       CURSOR bdump_cur IS
          SELECT TRIM(value)
          FROM v$parameter
          WHERE name = 'background_dump_dest'
       CURSOR sid_cur IS
          SELECT TRIM(instance_name)
          FROM v$instance
       CURSOR session_cur IS
          SELECT s.*
          FROM v$session s
          WHERE s.sid = dbms_support.mysid
       CURSOR audit_trail_cur(AUDSID IN NUMBER) IS
          SELECT *
          FROM dba_audit_trail
          WHERE sessionid = AUDSID
    BEGIN
       IF (USER = 'SYSTEM' OR USER = 'SYS') THEN
          -- Ignore this error
          NULL;
       ELSIF IS_SERVERERROR (1034) THEN
          -- Ignore this error
          NULL;
       ELSE
          -- get the sid
          OPEN sid_cur;
          FETCH sid_cur INTO sid_name;
          CLOSE sid_cur;
          -- get the location of the alert log
          OPEN bdump_cur;
          FETCH bdump_cur INTO bdump_dest;
          CLOSE bdump_cur;
          -- get the session information
          OPEN session_cur;
          FETCH session_cur INTO session_rec;
          CLOSE session_cur;
          -- get the audit_trail information if it exists
          OPEN audit_trail_cur(session_rec.audsid);
          FETCH audit_trail_cur INTO audit_rec;
          auditing := audit_trail_cur%FOUND;
          CLOSE audit_trail_cur;
          IF session_rec.program = 'MyProgram.exe' THEN
             NULL;  -- ignore actions from MyProgram - that's where I do maintenance
          ELSE
             -- compose the message
             msg := 'Subject: Oracle error '||' on '||sid_name||crlf;
             msg := msg||'To: '||recipient_address||crlf;
             msg := msg||'For more information see the alert log file located at:'||crlf;
             msg := msg||bdump_dest||'/alert_'||sid_name||'.log'||crlf;
             msg := msg||'or the error log file: $'||log_file_dir||'/'||log_file_name||crlf;
             msg := msg||'Error Time='||TO_CHAR(SYSDATE,'DD-Mon-YYYY HH24:MI:SS')||crlf;
             msg := msg||DBMS_UTILITY.FORMAT_CALL_STACK||crlf;
             LinesOfSQL := sql_txt(offending_sql);
             msg := msg||'Offending SQL is:'||crlf;
             FOR loop_counter IN offending_sql.FIRST..offending_sql.LAST
             LOOP
                msg := msg||offending_sql(loop_counter);
             END LOOP;
             msg := msg||crlf||'----- PL/SQL Error Stack -----'||crlf;
             msg := msg||DBMS_UTILITY.FORMAT_ERROR_STACK||crlf;
             msg := msg||'V$SESSION.SADDR='   ||session_rec.saddr   ||crlf;
             msg := msg||'V$SESSION.SID='     ||session_rec.sid     ||crlf;
             msg := msg||'V$SESSION.SERIAL#=' ||session_rec.serial# ||crlf;
             msg := msg||'V$SESSION.AUDSID='  ||session_rec.audsid  ||crlf;
             msg := msg||'V$SESSION.PADDR='   ||session_rec.paddr   ||crlf;
             msg := msg||'V$SESSION.USER#='   ||session_rec.user#   ||crlf;
             msg := msg||'V$SESSION.USERNAME='||session_rec.username||crlf;
             msg := msg||'V$SESSION.COMMAND=' ||session_rec.command ||crlf;
             msg := msg||'V$SESSION.OWNERID=' ||session_rec.ownerid ||crlf;
             msg := msg||'V$SESSION.TADDR='   ||NVL(session_rec.taddr   ,'Null')||crlf;
             msg := msg||'V$SESSION.LOCKWAIT='||NVL(session_rec.lockwait,'Null')||crlf;
             msg := msg||'V$SESSION.STATUS='  ||NVL(session_rec.status  ,'Null')||crlf;
             msg := msg||'V$SESSION.SERVER='  ||NVL(session_rec.server  ,'Null')||crlf;
             msg := msg||'V$SESSION.SCHEMA#=' ||session_rec.schema#||crlf;
             msg := msg||'V$SESSION.SCHEMANAME=' ||NVL(session_rec.schemaname,'Null')||crlf;
             msg := msg||'V$SESSION.OSUSER='     ||NVL(session_rec.osuser    ,'Null')||crlf;
             msg := msg||'V$SESSION.PROCESS='    ||NVL(session_rec.process   ,'Null')||crlf;
             msg := msg||'V$SESSION.MACHINE='    ||NVL(session_rec.machine   ,'Null')||crlf;
             msg := msg||'V$SESSION.TERMINAL='   ||NVL(session_rec.terminal  ,'Null')||crlf;
             msg := msg||'V$SESSION.PROGRAM='    ||NVL(session_rec.program   ,'Null')||crlf;
             msg := msg||'V$SESSION.TYPE='       ||NVL(session_rec.type      ,'Null')||crlf;
             msg := msg||'V$SESSION.SQL_ADDRESS='    ||session_rec.sql_address  ||crlf;
             msg := msg||'V$SESSION.SQL_HASH_VALUE=' ||NVL(TO_CHAR(session_rec.sql_hash_value) ,'Null')||crlf;
             msg := msg||'V$SESSION.PREV_SQL_ADDR='  ||session_rec.prev_sql_addr||crlf;
             msg := msg||'V$SESSION.PREV_HASH_VALUE='||NVL(TO_CHAR(session_rec.prev_hash_value),'Null')||crlf;
             msg := msg||'V$SESSION.MODULE='     ||NVL(session_rec.module              ,'Null')||crlf;
             msg := msg||'V$SESSION.MODULE_HASH='||NVL(TO_CHAR(session_rec.module_hash),'Null')||crlf;
             msg := msg||'V$SESSION.ACTION='     ||NVL(session_rec.action              ,'Null')||crlf;
             msg := msg||'V$SESSION.ACTION_HASH='||NVL(TO_CHAR(session_rec.action_hash),'Null')||crlf;
             msg := msg||'V$SESSION.CLIENT_INFO='||NVL(session_rec.client_info         ,'Null')||crlf;
             msg := msg||'V$SESSION.FIXED_TABLE_SEQUENCE='||NVL(TO_CHAR(session_rec.fixed_table_sequence),'Null')||crlf;
             msg := msg||'V$SESSION.ROW_WAIT_OBJ#='  ||NVL(TO_CHAR(session_rec.row_wait_obj#)  ,'Null')||crlf;
             msg := msg||'V$SESSION.ROW_WAIT_FILE#=' ||NVL(TO_CHAR(session_rec.row_wait_file#) ,'Null')||crlf;
             msg := msg||'V$SESSION.ROW_WAIT_BLOCK#='||NVL(TO_CHAR(session_rec.row_wait_block#),'Null')||crlf;
             msg := msg||'V$SESSION.ROW_WAIT_ROW#='  ||NVL(TO_CHAR(session_rec.row_wait_row#)  ,'Null')||crlf;
             msg := msg||'V$SESSION.LOGON_TIME='     ||NVL(TO_CHAR(session_rec.logon_time,'DD-Mon-YYYY HH24:MI:SS'),'Null')||crlf;
             msg := msg||'V$SESSION.LAST_CALL_ET='   ||NVL(TO_CHAR(session_rec.last_call_et)   ,'Null')||crlf;
             msg := msg||'V$SESSION.PDML_ENABLED='   ||NVL(session_rec.pdml_enabled   ,'Null')||crlf;
             msg := msg||'V$SESSION.FAILOVER_TYPE='  ||NVL(session_rec.failover_type  ,'Null')||crlf;
             msg := msg||'V$SESSION.FAILOVER_METHOD='||NVL(session_rec.failover_method,'Null')||crlf;
             msg := msg||'V$SESSION.FAILED_OVER='    ||NVL(session_rec.failed_over    ,'Null')||crlf;
             msg := msg||'V$SESSION.RESOURCE_CONSUMER_GROUP='||NVL(session_rec.resource_consumer_group,'Null')||crlf;
             msg := msg||'V$SESSION.PDML_STATUS='    ||NVL(session_rec.pdml_status    ,'Null')||crlf;
             msg := msg||'V$SESSION.PDDL_STATUS='    ||NVL(session_rec.pddl_status    ,'Null')||crlf;
             msg := msg||'V$SESSION.PQ_STATUS='      ||NVL(session_rec.pq_status      ,'Null')||crlf;
             IF auditing THEN
                msg := msg||'DBA_AUDIT_TRAIL.OS_USERNAME='  ||NVL(audit_rec.os_username,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.USERNAME='     ||NVL(audit_rec.username   ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.USERHOST='     ||NVL(audit_rec.userhost   ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.TERMINAL='     ||NVL(audit_rec.terminal   ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.TIMESTAMP='    ||TO_CHAR(audit_rec.timestamp,'DD-Mon-YYYY HH24:MI:SS')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.OWNER='        ||NVL(audit_rec.owner      ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.OBJ_NAME='     ||NVL(audit_rec.obj_name   ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.ACTION='       ||audit_rec.action   ||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.ACTION_NAME='  ||NVL(audit_rec.action_name   ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.NEW_OWNER='    ||NVL(audit_rec.new_owner     ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.NEW_NAME='     ||NVL(audit_rec.new_name      ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.OBJ_PRIVILEGE='||NVL(audit_rec.obj_privilege ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.SYS_PRIVILEGE='||NVL(audit_rec.sys_privilege ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.ADMIN_OPTION=' ||NVL(audit_rec.admin_option  ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.GRANTEE='      ||NVL(audit_rec.grantee       ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.AUDIT_OPTION=' ||NVL(audit_rec.audit_option  ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.SES_ACTIONS='  ||NVL(audit_rec.ses_actions   ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.LOGOFF_TIME='  ||NVL(TO_CHAR(audit_rec.logoff_time)  ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.LOGOFF_LREAD=' ||NVL(TO_CHAR(audit_rec.logoff_lread) ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.LOGOFF_PREAD=' ||NVL(TO_CHAR(audit_rec.logoff_pread) ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.LOGOFF_LWRITE='||NVL(TO_CHAR(audit_rec.logoff_lwrite),'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.LOGOFF_DLOCK=' ||NVL(audit_rec.logoff_dlock  ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.COMMENT_TEXT=' ||NVL(audit_rec.comment_text  ,'Null')||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.SESSIONID='    ||audit_rec.sessionid   ||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.ENTRYID='      ||audit_rec.entryid     ||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.STATEMENTID='  ||audit_rec.statementid ||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.RETURNCODE='   ||audit_rec.returncode  ||crlf;
                msg := msg||'DBA_AUDIT_TRAIL.PRIV_USED='    ||NVL(audit_rec.priv_used,'Null')||crlf;
             END IF;
             msg := msg||'-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-'||crlf||crlf;
             -- write the message to the error log file
             log_file_handle := UTL_FILE.FOPEN (log_file_dir, log_file_name, 'A',maxlinesize);
             UTL_FILE.PUT_LINE(log_file_handle,msg);
             UTL_FILE.FCLOSE(log_file_handle);
             -- send the message by Email
             mail_conn := UTL_SMTP.open_connection(smtp_relay, mail_port);
             UTL_SMTP.HELO(mail_conn, smtp_relay);
             UTL_SMTP.MAIL(mail_conn, sender_address);
             UTL_SMTP.RCPT(mail_conn, recipient_address);
             UTL_SMTP.DATA(mail_conn, msg);
             UTL_SMTP.QUIT(mail_conn);
          END IF; -- client_program = MyProgram.exe
       END IF;
    END;
    /

  • Send a mail with a picture from mime repository

    Hello,
    I want to send a mail with a picture from mime repository.
    The mail is sended OK, but the receiver hasn't  the picture on the mail  (don't find the picture).
    Here is my syntax :
       st_objtxt-line = '<IMG SRC="SAPR3://005056B2002D1EE3BF8F5B5ECDCA55E1" ALIGN=RIGHT WIDTH="100" HEIGHT="80">'.
        append st_objtxt to t_objtxt.
    "SAPR3://005056B2002D1EE3BF8F5B5ECDCA55E1" is url of my object mime .
    Have you a idea to resolve this problem ? It's the syntax OK ?
    Thank for your responses.
    Regards.
    JCAIL

    Have you tried storing your picture as a business document?  Have a look at the class  cl_bds_document_set to read your picture from the BDS.

Maybe you are looking for

  • Conditional Display on multiple items?

    Is it possible to use multiple items in the conditional display region of a report? For example I'm trying to use the "Value of Item in Expression 1= Expression 2" and when I populate 1 item with the value in expression 2 it works just great but if I

  • Outlook Sync Problem: Member Not Fo

    Anyone experience any problems when trying to synch Outlook 2003 with their ZM? I start the process, select Contacts, Tasks, and Calendar. After selecting the Contacts Folder for synch on the next page, I get a message from Outlook stating that anoth

  • Connecting iPhone to PC or laptop

    Can I connect an iPHone to my PC or laptop without jailbreaking it. I don't want to nor do I intend to do that. It certainly would be nice to us a large screen when I have either of the computers available to me. Thanks so much.

  • Depreciation forecast report

    Hello All, I need a depreciation forecast report that gives me the depreciation by month. It needs to subtotal by cost center and asset class. Eg if cost center X has deprecaition of 5000 which is comprised of asset class A of $1000 Asset classs B of

  • Disable tab/window priority page loading

    I'm going to use youtube as an example, but this is true for many other sites. Say I go to youtube.com and cmd-click on a couple links so they open in new tabs. The videos in those tabs won't begin loading until their tab is selected. Again, it's tru