How to send mail in  HTML  format using SMTP

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

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

Similar Messages

  • How to send mail in html format in jsp???

    Hello everybody,
    I have two jsp pages.In one page I have the heading like Date,Transaction.I am retriving data from my second jsp page.And I hae included the second jsp page to my first jsp page.How to send mail this content in html format.
    Thanks
    Srikant

    MimeMessage m = new MimeMessage(session);
    BodyPart messageBodyPart = new MimeBodyPart();
    messageBodyPart.setContent(content, "text/html");this if u need to send a mail content as html

  • How to send mails in HTML format from the send mail step of workflow?

    Hi,
    I have a requirement where I need to send mails in the html format from the send mail step of the workflows.
    But what I found out that the html tags are not renderd and as such the output is in plain text.
    I know that there is an alternative of using an activity step and use my own custom code from within there,But due to certain business constraints, I need to use the send mail step only.
    My SCOT settings are all right.
    Please let me know how it can be done.
    Thanks,
    Samrat.

    Samrat,
    It can't be done, you have to use your own activity step.
    What are these constraints that refrain you from doing that?
    Rgds,
    Patrick

  • How to send mails to multiple recipents using SO_DOCUMENT_SEND_API

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

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

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

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

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

  • Send mail in HTML Format in Service Desk

    Dear Friends,
    We want to send email in html format to every user in service desk, how can we figure it?
    Thanks in advance
    Regards,

    Hello Eray,
    You will want to have a look at this document and hopefully it will assist you accomplish what you need.
    http://service.sap.com/~sapidb/011000358700001903822008E
    Regards,
    Paul

  • How to send the body of mail in html format using servlet

    Hi
    i developed an servlet using sun.net.smtp.SmtpClient package,my servlet receiving data from an form,i can able to send mail successfully,but my mail body part is in the text format,but i would like to send it as an html format,for ex <input type="text" size="25" name="Name"> as an input field with value received from the form instead of showing tags as i mentioned<input type="text" size="25" name="Name"> ,any help would be appreciated.
    Regards.

    See this program
    But here whats the problem is ,
    some maiservers doesnot support html code if u send this mail to yahoo account it will show html code as it is,
    hotmail account encodes the html and shows proper fonts and headings
    import java.io.*;
    import java.util.*;
    import java.net.*;
    import sun.net.smtp.SmtpClient;
    public class SendMail {
              public static void main(String args[]){
              int i = 0;
              //while (true) {
              SmtpClient mail;
              try{
                   i++;
                   String email = "[email protected]";
                   String from="[email protected]";
                   mail=new SmtpClient("bizpivot.com");
                   mail.from(from);
              mail.to(email);
                   PrintStream msg=mail.startMessage();
                   msg.println("To: " +email);
                   msg.println("Subject: Hai" i "!!!");
                   msg.println("<html><head><title>Untitled</title></head><body bgcolor='red' text='#00ffff'><font face='Courier New' size='+3'>Hai How are you Man!!!</font></body></html>");
                   mail.closeServer();
              System.out.println(i);
              catch(Exception e){e.printStackTrace();}

  • Send mail in HTML format

    Is it possible with ODISendMail to send mail not in simple text but in HTML?
    If no... how can I do that?

    If you are looking for capturing the error in the HTML format that can be done by using odioutfile and save the file as HTML and use the required command at the message tab to capture the error .
    in the Next step use - odisendmail attach the above html file as attached.

  • How to send CC and/or BC using smtp-package

    I know how to send a message using the sun.net.smtp.SmtpClient.
    How can I include CC and/or BC ?
    Do I have to send this message a second/third time?

    If you are using raw SMTP then you could look through RFC 821 to see if your answer is there:
    http://www.faqs.org/rfcs/rfc821.html

  • How to send mails to dynamic receivers using XSLT mapping

    Hi All,
    I have a problem with the mail attributes in xslt mapping. I have a condition on a source field, based on which the "TO" attribute should vary.
    For Example :  If ROOT/HEADER/XYZ = 001 then receiver should be some abc email id
    If ROOT/HEADER/XYZ = 002 then receiver should be
    pqr email id.
    Can anyone help me out of this
    Thanks in advance.
    Regards,
    Lakshmi.

    Hi Lakshmi,
    you have to create an appropriate mapping for this. As said, the mentioned mail package format will be your message. The message will be analyzed by the mail adapter and after this the TO field will be filled with the correct value you will use. The structure inserted into the content fields will be send in the mail body or, if set in the configuration, as an attachement of the mail (as far as i know (-; )
    Example:
    Original structure:
    <ContentStructure>
      <ValueA>ID1</ValueA>
      <ValueB>XYZ</ValueB>
    </ContentStructure>
    Extract of an XSLT-Mapping (as an example, you can use the mapping type you prefer):
    <ns:Mail xmlns:ns="http://sap.com/xi/XI/Mail/30">
      <Subject>Subject</Subject>
      <From>namea(at)company.com</From>
      <To>
        <xsl:choose>
          <xsl:when test="ContentStructure/ValueA='ID1'">
            nameb(at)companyb.com
          </xsl:when>
          <xsl:when test="ContentStructure/ValueA='ID2'">
            namec(at)companyc.com
          </xsl:when>
        </xsl:choose>
      </To>
      <Reply_To />
      <Content_Type>text/plain</Content_Type>
      <Content>
        This is the content.
      </Content>
    </ns:Mail>
    If you try something like this, you will be able to set the TO email address dynamical.
    Rregards,
    Lars

  • How to send mail to a person using BSPs?

    Hi Group,
    I have a requirement for developing a BSP application for "Expenses" claim.
    Thing is that, the person will enter some details like (start date, end date,Expenses occured by him and etc.,) and presses a button (<b>Accept</b>).
    When he presses the "<b>Accept</b>" button, an Email has to be sent to the Approver of the Expenses.
    Could you please let me know how I can achieve this requirement?
    Thanks in advance.
    Regards,
    Vishnu.

    Hi,
    Pls check /people/eddy.declercq/blog/2006/04/03/unknown-thus-unloved
    Eddy
    PS. Reward the useful answers and you will get <a href="http:///people/baris.buyuktanir2/blog/2007/04/04/point-for-points-reward-yourself">one point</a> yourself!

  • How to send a mail in html format from a send mail workflow node ?

    Dear all,
    Do you know if it is possible to send an e-mail in HTML format (instead of RAW) from a "send mail" node in a workflow ?  ... if "yes", please, let me know.
    (I need to do that because I want to use the "href" tag to insert an hyperlink inside the e-mail)
    - I haven't found any parameter to specify the format of the e-mail.
    - Inside SCOT I tried to change the parameters for the SMTP node... without success.
    - I don't want to use a task calling the FM SO_OBJECT_SEND.
    Nicolas

    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

  • How to send program output as  mail in HTML format

    Hi Friends,
    I have a BDc which runs in background and its been Stored in my system and displayed as HTML format.
    My requirement is now i want that Same HTML file which i am displaying to be sent as a mail in HTML format itself..Kindly help me on this
    Thanks in advance
    kishore

    Hi,
    Below sample program might give you idea on sending HTML attachment.
    TYPES: BEGIN OF t_sal_ord,
               vbeln TYPE vbeln_va,
               posnr TYPE posnr_va,
               auart TYPE auart,
               vkorg TYPE vkorg,
               matnr TYPE matnr,
             END OF t_sal_ord.
      DATA: i_sal_ord TYPE STANDARD TABLE OF t_sal_ord,
            i_header TYPE STANDARD TABLE OF w3head,
            i_fields TYPE STANDARD TABLE OF w3fields,
            i_html TYPE STANDARD TABLE OF w3html,
            wa_header TYPE w3head.
      DATA: i_fcat TYPE lvc_t_fcat,
            wa_fcat TYPE lvc_s_fcat.
      DATA: g_send_request TYPE REF TO cl_bcs,
            g_document TYPE REF TO cl_document_bcs,
            g_recipient TYPE REF TO cl_cam_address_bcs,
            g_cx_bcs TYPE REF TO cx_bcs,
            g_sent_to_all TYPE os_boolean.
      DATA: g_lines TYPE i,
            g_size TYPE so_obj_len.
      PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY,
                  p_mailad TYPE ad_smtpadr OBLIGATORY.
    START-OF-SELECTION.
      SELECT a~vbeln b~posnr a~auart a~vkorg b~matnr
        INTO TABLE i_sal_ord
        UP TO 20 ROWS
        FROM vbak AS a
        INNER JOIN vbap AS b
        ON a~vbeln  = b~vbeln
        WHERE a~vkorg = p_vkorg.
      wa_fcat-coltext = 'SalesOrd#'.
      APPEND wa_fcat TO i_fcat.
      wa_fcat-coltext = 'Item#'.
      APPEND wa_fcat TO i_fcat.
      wa_fcat-coltext = 'OrdType'.
      APPEND wa_fcat TO i_fcat.
      wa_fcat-coltext = 'Sales.Org'.
      APPEND wa_fcat TO i_fcat.
      wa_fcat-coltext = 'Material'.
      APPEND wa_fcat TO i_fcat.
      LOOP AT i_fcat INTO wa_fcat.
        wa_header-text = wa_fcat-coltext.
        CALL FUNCTION 'WWW_ITAB_TO_HTML_HEADERS'
          EXPORTING
            field_nr = sy-tabix
            text     = wa_header-text
            size     = '2'
            fgcolor  = 'BLACK'
            bgcolor  = 'VIOLET'
            font     = 'CALIBRI'
          TABLES
            header   = i_header.
        CALL FUNCTION 'WWW_ITAB_TO_HTML_LAYOUT'
          EXPORTING
            field_nr = sy-tabix
            size     = '2'
            fgcolor  = 'BLACK'
            bgcolor  = 'WHITE'
            font     = 'CALIBRI'
          TABLES
            fields   = i_fields.
      ENDLOOP.
      wa_header-text = 'Sales Order Details'.
      wa_header-size = '2'.
      wa_header-font = 'CALIBRI'.
      CALL FUNCTION 'WWW_ITAB_TO_HTML'
       EXPORTING
    *     TABLE_ATTRIBUTES       = 'BORDER=1'
         table_header           = wa_header
    *     ALL_FIELDS             = 'X'
        TABLES
          html                   = i_html
          fields                 = i_fields
          row_header             = i_header
          itable                 = i_sal_ord.
      TRY .
          g_send_request = cl_bcs=>create_persistent( ).
          g_document = cl_document_bcs=>create_document(
                        i_type  = 'RAW'
    *                i_text  = i_content[]  " Body for Mail
                        i_subject = 'Sales Order Details' ).
          DESCRIBE TABLE i_html LINES g_lines.
          g_size = g_lines * 2 * 255.
          CALL METHOD g_document->add_attachment
            EXPORTING
              i_attachment_type    = 'HTM'
              i_attachment_subject = 'Sales Order Details'
              i_attachment_size    = g_size
              i_att_content_text   = i_html[].
          g_send_request->set_document( g_document ).
    g_recipient = cl_cam_address_bcs=>create_internet_address( p_mailad ).
          g_send_request->add_recipient(
             EXPORTING
               i_recipient = g_recipient
               i_express = 'X' ).
          g_send_request->set_send_immediately( 'X' ).
          g_send_request->send(
              EXPORTING
                i_with_error_screen = 'X'
              RECEIVING
                result = g_sent_to_all ).
          COMMIT WORK.
        CATCH cx_bcs INTO g_cx_bcs.
          WRITE:/ g_cx_bcs->error_type.
      ENDTRY.
    Kind Regards
    Eswar

  • How to send Mailing Spool Details of Background jobin EXCEL format

    Dear All,
    Hope every one doing awesome.
    As per client requirement we need to send spool detail to user in EXCEL format.
    http://sapignite.com/sending-mail-for-background-job/
    As per the mentioned thread ABAPER created the code and we are getting mails in HTML format.
    Now the user wants the files in EXCEL format.
    I had checked in SCOT and doesn't found any useful setting that will make the required changes.
    Any other suggestion ?
    Tons of thanks for your support.
    Regards
    Nikhil

    need solution..

  • How can send mails using hotmail/rediffmail domain name?

    I have used the below code to send a mail using javamail API?Even when I am sending my application does not have notified any of error/exceptions,But the message is not reached to I have given receipient's address in the to field.
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.activation.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    public class Sendmail1 extends HttpServlet {
    private String smtpHost;
    // Initialize the servlet with the hostname of the SMTP server
    // we'll be using the send the messages
    public void init(ServletConfig config)
    throws ServletException {
    super.init(config);
    smtpHost = config.getInitParameter("smtpHost");
    //smtpHost = "sbm5501";
    smtpHost = "www.rediffmail.com";
    public void doGet(HttpServletRequest request,HttpServletResponse response)
    throws ServletException, java.io.IOException {
    String from = request.getParameter("from");
    String to "[email protected]";
    String cc = "[email protected]";
    String bcc ="[email protected]";
    String smtp ="www.rediffmail.com";
    String subject = "hai";
    String text = "Hai how r u";
    PrintWriter writer = response.getWriter();
    if (subject == null)
    subject = "Null";
    if (text == null)
    text = "No message";
    String status;
    try {
    // Create the JavaMail session
    java.util.Properties properties = System.getProperties();
    if (smtp == null)
    smtp = "www.rediffmail.com";
    properties.put("mail.smtp.host", smtp);
    Session session = Session.getInstance(properties, null);
    //to connect
    //Transport transport =session.getTransport("smtp");
    //transport.connect(smtpHost,user,password);
    // Construct the message
    MimeMessage message = new MimeMessage(session);
    // Set the from address
    Address fromAddress = new InternetAddress(from);
    message.setFrom(fromAddress);
    // Parse and set the recipient addresses
    Address[] toAddresses = InternetAddress.parse(to);
    message.setRecipients(Message.RecipientType.TO,toAddresses);
    Address[] ccAddresses = InternetAddress.parse(cc);
    message.setRecipients(Message.RecipientType.CC,ccAddresses);
    Address[] bccAddresses = InternetAddress.parse(to);
    message.setRecipients(Message.RecipientType.BCC,bccAddresses);
    // Set the subject and text
    message.setSubject(subject);
    message.setText(text);
    Transport.send(message);
    //status = "<h1>Congratulations,</h1><h2>Your message was sent.</h2>";
    } catch (AddressException e)
    status = "There was an error parsing the addresses. " + e;
    } catch (SendFailedException e)
    status = "<h1>Sorry,</h1><h2>There was an error sending the message.</h2>" + e;
    } catch (MessagingException e)
    status = "There was an unexpected error. " + e;
    // Output a status message
    response.setContentType("text/html");
    writer.println("<title>sendForm</title><body bgcolor= ><b><h3><font color=green><CENTER>CALIBERINFO.COM</CENTER></h3>Your message was sent to recepient(s).<br><font color=red>"+"\n"+to);
    writer.println("<br><br><a href=e:/mail/javamail/mail.html>back to compose</a>");
    writer.close();
    Please any one help me out from this probs.
    Awaiting for yours reply,
    or give me a reply to: [email protected]
    Regards,
    @maheshkumar.k

    Hi,
    how can send mails using hotmail/rediffmail domain name?In your java application,you specified www.rediffmail.com as your
    smtp server.But that is the address of that website.Try will a smtp
    server instead.For a list of free smtp servers,please visit http://www.thebestfree.net/free/freesmtp.htm
    Hope this helps.
    Good Luck.
    Gayam.Srinivasa Reddy
    Developer Technical Support
    Sun Microsystems
    http://www.sun.com/developers/support/

Maybe you are looking for