Can I send email using Java from my localhost(Tomcat) with Internet connect

Hi friends,
Please tell me can I send email from my localhost (Tomcat) using Java when my computer is connected to Internet?
I don't have any SMTP username or password or the like, as I found in some codes available in net.
Please suggest and any simple code if possible.
Please don't send me the link of JavaMail API to read.
---Sujoy

Thank you for the link. Though I have not tested the provided code, I will test it.
--Sujoy                                                                                                                                                                                       

Similar Messages

  • How can I send email using two different email address that both link back to my one exchange account on my Ipad mini

    How can I send email using two different email address that both link back to my one exchange account on my Ipad mini? 
    On my PC I simply have a master return email address and use a POP for the secondary address.  Both are through the one exchange account without a problem.  I need to be able to do the same on my Ipad.

    Ah, I should have made that clear.  My domain didn't come from google.  It was purchased at and is hosted at dreamhost, but I haven't used their email servers in years - I just route everything through gmail.  I actually have a bunch of domains (with websites).
    Gmail has an option that lets someone with custom domains send (and receive) email through gmail using the custom domain once Google confirms proper ownership of the domain (to prevent spammers and such).  Gmail has a setting for "send email as" which allows gmail to be sent using a custom domain as the sender.  I'm pretty sure Apple's old mobileme had this feature too, but I didn't use it.

  • How to send emails using java code

    Hi,
    can any give me some sample code for sending emails using java language

    JavaMail quick start
    jGuru: Fundamentals of the JavaMail API

  • I am unable to send emails using mail from my btinternet and yahoo accounts similar problem to others with mobile me accounts on lion any suggestions?

    I am unable to send emails using mail from my btinternet and yahoo accounts similar problem to others with mobile me accounts on lion any suggestions?

    Do I need to delete all my email accounts and start again?

  • Can't send email using wifi. Spent 30 min troubleshooting with my email service provider who finally told me to contact Apple

    Can't send email using wifi. Spent 30 min troubleshooting with my email service provider who finally told me to contact Apple.
    It doesn't work when I can't get 3G, whether at home or overseas. Receives no problem, and 3G works fine when it's available.

    Maybe it is a 3GS. Anyway, I get the error that the network is not responding, and to check my settings. My ISP is Uniserve (Canada) but I am trying to use Telus (at home, where there is no 3G in my neighbourhood) or whatever is available as I travel eg. US or Europe for outgoing mail when 3G is not available. My husband has no problem with his iphone 4 when he sends email the same way usinf wifi.

  • HT5654 after update to the latest version on my ipad, it no longer connects to the internet nor can i send emails.  when plugged in to sync with itunes, it remains 'stuck' at syncing  step 2 of 7 backing up.  has anyone had similar problems? any solutions

    after update to the latest version on my ipad, it no longer connects to the internet nor can i send emails.  when plugged in to sync with itunes, it remains 'stuck' at syncing  step 2 of 7 backing up.  has anyone had similar problems? any solutions?

    I had this problem.  I held down the power switch to power down completely.  Takes a few seconds.  Then use the power switch to turn on.  Might take a couple goes.
    Kirk

  • Sending Email using java code

    I am using the following code to send an email from my java servlet but the problem is, when it is on its own it works fine but as soon as I combine it with some code to submit data into a postgres database it sometimes does not perform could it be because im missing some close statements??
    //grades to submit grades starts here
                                                           String [] paramValues = req.getParameterValues("Mark");
                                                      for(int i=0; i<paramValues.length;i++)
                                                           String [] paramValues2 = req.getParameterValues("StudentExamNumber");
                                                                String Mark = paramValues;
                                                                String ExamNo = paramValues2[i];
                                                                //testing purposes
                                                                out.println("<tr><td>"+ExamNo+"</td>");
                                                                out.println("<td>"+Mark+"</td>");
                                                                try
                                                           st = conn.createStatement();
                                                           query = "SELECT StudentNo FROM STUDENTS"+WebCourse2+ " where ExamNo='"+ExamNo+"'";
                                                           rs = st.executeQuery(query);
                                                           if(rs !=null)
                                                                          while(rs.next())
                                                                               String StudentNo=rs.getString("StudentNo");
                                                                               //testing purposes
                                                                               //out.println("<td>"+StudentNo+"</td></tr>");
                                                                               here
                                                                               st4 = conn.createStatement();
                                                                     query4 = "select MAX(entryno) from STUDENTRESULTSFORCOURSE"+WebCourse2+" WHERE STUDENTNO='"+StudentNo+"'";
                                                                     rs4 = st4.executeQuery(query4);
                                                                     if(rs4 !=null)
                                                                                    while(rs4.next())
                                                                                         EntryNo = rs4.getInt(1);
                                                                                    }//end rs4 while
                                                                                    rs4.close();
                                                                               }//end rs4 if
                                                                     out.println("<tr><td>EntryNo= "+EntryNo+"</td>");
                                                                               EntryNo = EntryNo + 1;
                                                                               out.println("<td>NewEntryNo= "+EntryNo+"</td></tr>");
                                                                               //Submitting grades to database/
                                                                     st3 = conn.createStatement();
                                                                     insert = "insert into STUDENTRESULTSFORCOURSE"+WebCourse2+" (StudentNo, CourseCode, AttemptNo, ExamMark, EntryNo, EnteredBy) values ('"+StudentNo+"', '"+WebCourse2+"', 1,'"+Mark+"',"+EntryNo+",'"+WebUsername2+"')";
                                                                     st3.executeUpdate(insert);
                                                                          }//end rs while
                                                                          rs.close();
                                                                     }//end rs if
                                                                }//end try
                                                                catch (SQLException e)
                                                                     System.out.println("Error: "+e.getMessage());
                                                           }//end for loop     
                                                           //code to submit grades ends here
                                                           //code used to send email starts here
                                                           String m_sHostName="localhost";
                                                      int m_iPort=25;
                                                           try
                                                                // Open port to server
                                                                smtpSocket = new Socket(m_sHostName, m_iPort);
                                                                os = new DataOutputStream(smtpSocket.getOutputStream());
                                                                is = new DataInputStream(smtpSocket.getInputStream());
                                                                if(smtpSocket != null && os != null && is != null)
                                                                     // Connection was made. Socket is ready for use.
                                                                     System.out.println("Connection was made. Socket is ready for use.");
                                                                     try
                                                                          // The email address that the server
                                                                          // you are using know user as.
                                                                          os.writeBytes("MAIL From: <[email protected]>\r\n");
                                                                          // Who the email is going to.
                                                                          os.writeBytes("RCPT To: <[email protected]>\r\n");
                                                                          //send a CC to:
                                                                          os.writeBytes("RCPT Cc: <[email protected]>\r\n");
                                                                          // add the message and the
                                                                          // header of the email to be sent out.
                                                                          os.writeBytes("DATA\r\n");
                                                                          os.writeBytes("X-Mailer: Via Java\r\n");
                                                                          os.writeBytes("From: "+WebUsername2+"<[email protected]>\r\n");
                                                                          os.writeBytes("To: Marie <[email protected]>\r\n");
                                                                          //Again if you want to send a CC then add this.
                                                                          os.writeBytes("Cc: ProfCuthbert <[email protected]>\r\n");
                                                                          String sMessage = "ELECTRONIC ENGINEERING EXAM COLLATION SYSTEM EMAIL\n\nThe results for the following course have been submitted by the following member of staff\n\nCOURSE: "+WebCourse2+"\n\nSUBMITTED BY: "+WebUsername2+" \n\nPLEASE LOCK COURSE NOW IN ORDER TO PREVENT ANY FURTHER SUBMISSIONS TO BE MADE BY USERS.";
                                                                          os.writeBytes("Subject: A SUBMISSION HAS BEEN MADE FOR COURSE "+WebCourse2+"\r\n");
                                                                          os.writeBytes(sMessage + "\r\n");
                                                                          os.writeBytes("\r\n.\r\n");
                                                                          os.writeBytes("QUIT\r\n");
                                                                          // Now send the email off and check the server reply.
                                                                          // Once an OK is reached you are complete.
                                                                          String responseline;
                                                                          //for testing purposes
                                                                          //out.println(responseline = is.readLine());
                                                                          while((responseline = is.readLine())!=null)
                                                                          //for testing purposes
                                                                          //out.println("responseline= "+responseline+"<br>");
                                                                          //out.println("responseline.indexOf(Ok)= "+responseline.indexOf("Ok"));
                                                                          if(responseline.indexOf("Ok") != -1)
                                                                          break;
                                                                          if(responseline.indexOf("Ok") == -1)
                                                                          confirm=1;
                                                                          if (confirm==1)
                                                                          out.println("<br>the marks have been submitted thank you");
                                                                          catch(Exception e)
                                                                          {  System.out.println("Cannot send email as an error occurred.");
                                                                               out.println("Cannot send email as an error occurred.");
                                                           catch(Exception e)
                                                           { System.out.println("Host " + m_sHostName + "unknown"); }
    Does anyone know what the problem is??
    thanks
    tzaf

    i close them later in the program. Ive made sure they are all closed I have a feeling that it could be coming from here....
    //code used to send email starts here
                                                           String m_sHostName="localhost";
                                                      int m_iPort=25;
                                                           try
                                                                // Open port to server
                                                                smtpSocket = new Socket(m_sHostName, m_iPort);
                                                                os = new DataOutputStream(smtpSocket.getOutputStream());
                                                                is = new DataInputStream(smtpSocket.getInputStream());
                                                                if(smtpSocket != null && os != null && is != null)
                                                                     // Connection was made. Socket is ready for use.
                                                                     System.out.println("Connection was made. Socket is ready for use.");
                                                                     try
                                                                          // The email address that the server
                                                                          // you are using know user as.
                                                                          os.writeBytes("MAIL From: <email address>\r\n");
                                                                          // Who the email is going to.
                                                                          os.writeBytes("RCPT To: <email address>\r\n");
                                                                          //send a CC to:
                                                                          os.writeBytes("RCPT Cc: <email address>\r\n");
                                                                          // add the message and the
                                                                          // header of the email to be sent out.
                                                                          os.writeBytes("DATA\r\n");
                                                                          os.writeBytes("X-Mailer: Via Java\r\n");
                                                                          os.writeBytes("From: "+WebUsername2+"<email address>\r\n");
                                                                          os.writeBytes("To: hello<email address>\r\n");
                                                                          //Again if you want to send a CC then add this.
                                                                          os.writeBytes("Cc: hello <email address>\r\n");
                                                                          String sMessage = "ELECTRONIC ENGINEERING EXAM COLLATION SYSTEM EMAIL\n\nThe results for the following course have been submitted by the following member of staff\n\nCOURSE: "+WebCourse2+"\n\nSUBMITTED BY: "+WebUsername2+" \n\nPLEASE LOCK COURSE NOW IN ORDER TO PREVENT ANY FURTHER SUBMISSIONS TO BE MADE BY USERS.";
                                                                          os.writeBytes("Subject: A SUBMISSION HAS BEEN MADE FOR COURSE "+WebCourse2+"\r\n");
                                                                          os.writeBytes(sMessage + "\r\n");
                                                                          os.writeBytes("\r\n.\r\n");
                                                                          os.writeBytes("QUIT\r\n");
                                                                          // Now send the email off and check the server reply.
                                                                          // Once an OK is reached you are complete.
                                                                          String responseline;
                                                                          //for testing purposes
                                                                          //out.println(responseline = is.readLine());
                                                                          while((responseline = is.readLine())!=null)
                                                                          //for testing purposes
                                                                          //out.println("responseline= "+responseline+"<br>");
                                                                          //out.println("responseline.indexOf(Ok)= "+responseline.indexOf("Ok"));
                                                                          if(responseline.indexOf("Ok") != -1)
                                                                          break;
                                                                          if(responseline.indexOf("Ok") == -1)
                                                                          confirm=1;
                                                                          if (confirm==1)
                                                                          out.println("<br>the marks have been submitted thank you");
                                                                          catch(Exception e)
                                                                          {  System.out.println("Cannot send email as an error occurred.");
                                                                               out.println("Cannot send email as an error occurred.");
                                                           catch(Exception e)
                                                           { System.out.println("Host " + m_sHostName + "unknown"); }
                                                           //code used to send email ends here
    do i need to close is and os?
    thanks
    tzaf

  • Sending email using java

    Im using this code to do this, but i have a feeling that I need to close os and is is that the case? do i need to close anything else?
    thanks
    tzaf
    //code used to send email starts here
                                                           String m_sHostName="localhost";
                                                      int m_iPort=25;
                                                           try
                                                                // Open port to server
                                                                smtpSocket = new Socket(m_sHostName, m_iPort);
                                                                os = new DataOutputStream(smtpSocket.getOutputStream());
                                                                is = new DataInputStream(smtpSocket.getInputStream());
                                                                if(smtpSocket != null && os != null && is != null)
                                                                     // Connection was made. Socket is ready for use.
                                                                     System.out.println("Connection was made. Socket is ready for use.");
                                                                     try
                                                                          // The email address that the server
                                                                          // you are using know user as.
                                                                          os.writeBytes("MAIL From: <[email protected]>\r\n");
                                                                          // Who the email is going to.
                                                                          os.writeBytes("RCPT To: <[email protected]>\r\n");
                                                                          //send a CC to:
                                                                          os.writeBytes("RCPT Cc: <[email protected]>\r\n");
                                                                          // add the message and the
                                                                          // header of the email to be sent out.
                                                                          os.writeBytes("DATA\r\n");
                                                                          os.writeBytes("X-Mailer: Via Java\r\n");
                                                                          os.writeBytes("From: "+WebUsername2+"<[email protected]>\r\n");
                                                                          os.writeBytes("To: Marie <[email protected]>\r\n");
                                                                          //Again if you want to send a CC then add this.
                                                                          os.writeBytes("Cc: ProfCuthbert <[email protected]>\r\n");
                                                                          String sMessage = "ELECTRONIC ENGINEERING EXAM COLLATION SYSTEM EMAIL\n\nThe results for the following course have been submitted by the following member of staff\n\nCOURSE: "+WebCourse2+"\n\nSUBMITTED BY: "+WebUsername2+" \n\nPLEASE LOCK COURSE NOW IN ORDER TO PREVENT ANY FURTHER SUBMISSIONS TO BE MADE BY USERS.";
                                                                          os.writeBytes("Subject: A SUBMISSION HAS BEEN MADE FOR COURSE "+WebCourse2+"\r\n");
                                                                          os.writeBytes(sMessage + "\r\n");
                                                                          os.writeBytes("\r\n.\r\n");
                                                                          os.writeBytes("QUIT\r\n");
                                                                          // Now send the email off and check the server reply.
                                                                          // Once an OK is reached you are complete.
                                                                          String responseline;
                                                                          //for testing purposes
                                                                          //out.println(responseline = is.readLine());
                                                                          while((responseline = is.readLine())!=null)
                                                                          //for testing purposes
                                                                          //out.println("responseline= "+responseline+"<br>");
                                                                          //out.println("responseline.indexOf(Ok)= "+responseline.indexOf("Ok"));
                                                                          if(responseline.indexOf("Ok") != -1)
                                                                          break;
                                                                          if(responseline.indexOf("Ok") == -1)
                                                                          confirm=1;
                                                                          if (confirm==1)
                                                                          out.println("<br>the marks have been submitted thank you");
                                                                          catch(Exception e)
                                                                          {  System.out.println("Cannot send email as an error occurred.");
                                                                               out.println("Cannot send email as an error occurred.");
                                                           catch(Exception e)
                                                           { System.out.println("Host " + m_sHostName + "unknown"); }
                                                           //code used to send email ends here

    any thoughts?
    thanks
    tzaf

  • Can I send email using my own domain address with iCloud the way I can with gmail?

    Let's say I own mydomain.com and have a [email protected] email account.  I have set that up to forward to gmail, and that would be easy to switch to iCloud.  Here's the tricky part: gmail allows me to send email as [email protected]  I've been doing this for years and it works, but I'd like to switch from gmail to iCloud.  Can I set up this same behavior with an iCloud @me.com address (which I already have but haven't been using yet)?  I know I can obviously switch the forwarding of incoming mail to my @me.com address...  but can I send [email protected] email through iCloud the way I can with gmail?  All of my devices are Apple: a Mac Mini using Apple's Mail app, and an iPhone and an iPad both using the Apple email app, so I'd rather switch everything over from gmail to iCloud.
    P.S.  Awe, c'mon Apple.  Don't turn those fake addresses into links.  I just used them for the sake of giving an example.

    Ah, I should have made that clear.  My domain didn't come from google.  It was purchased at and is hosted at dreamhost, but I haven't used their email servers in years - I just route everything through gmail.  I actually have a bunch of domains (with websites).
    Gmail has an option that lets someone with custom domains send (and receive) email through gmail using the custom domain once Google confirms proper ownership of the domain (to prevent spammers and such).  Gmail has a setting for "send email as" which allows gmail to be sent using a custom domain as the sender.  I'm pretty sure Apple's old mobileme had this feature too, but I didn't use it.

  • Can't send email using yahoo through apple devices, any ideas?

    I cannot send an email using yahoo through any of my Apple devices, although email sent get through. It states "connection to the outgoing server ' apple.smpt.mail.yahoo.com' failed.
    Does anyone know how to restore?

    I am sorry that I cannot help you but I am having a similar problem. I can rec/send email but my email is duplicated and a pop up says that my server is not responding. I have spent most of the afternoon trying to get it corrected. I finally decided to take it to my Apple store next week.
    Good luck to us!

  • Can not send email using 3G

    I cannot send email using 3G with the new ios5. I have iphone4s

    I use cox here in new orleans, and it works fine - I upgraded my 3GS last Monday, and have been using since then. I just tried to send an email to see if there was something going on with Cox, and I was able to send it.
    Do you want my settings? ( I do use pop.east.cox.net, so it could be something wrong with another server).
    Message was edited by: Noladave

  • I am not able to send email using JAVA API to outer email

    If I am trying to send email from my company account to yahoo I am getting following errors:
    javax.mail.SendFailedException: Invalid Addresses;
    nested exception is:
    com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay
    for [email protected]
    at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1196)
    at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:584)
    at javax.mail.Transport.send0(Transport.java:169)
    at javax.mail.Transport.send(Transport.java:98)
    at MailSend.main(MailSend.java:116)
    Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to rel
    ay for [email protected]
    at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1047)
    ... 4 more
    com.sun.mail.smtp.SMTPAddressFailedException: 550 5.7.1 Unable to relay for mkba
    [email protected]
    at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1047)
    at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:584)
    at javax.mail.Transport.send0(Transport.java:169)
    at javax.mail.Transport.send(Transport.java:98)
    at MailSend.main(MailSend.java:116)
    Please let me know the reason for the same.

    Unable to relay - This happened because your Company network don't permit relay. Do talk to the network administrator and check with way safe you can send.
    I got the same problem, now im using through gmail.

  • Send Email using Java

    May i know how to send the email by using java?

    heres my final i did for java 1 last year (it was a simple email sending program:
    //java FINAL!
    import javax.swing.*;
    import java.net.URL;
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    public class EmailProg extends JPanel implements ActionListener {
        protected JTextArea textArea;
        protected String newline = "\n";
        static final private String composemail = "compose";
        static final private String sendmail = "send";
        static final private String about = "about";
        static final private String submit = "submit";
        static final private String exit = "exit";
        JLabel lSubmit = new JLabel("Submit");
        JButton subbutton = new JButton();
        JTextArea emailfrom = new JTextArea(1,1);
        JTextArea emailto = new JTextArea(1, 1);
        JTextArea emailsubject = new JTextArea(1, 1);
        JTextArea emailmessage = new JTextArea(25, 1);
        //------BAG LAYOUT
        JLabel lFrom = new JLabel("From:");
        JTextField cFrom = new JTextField(32);
        JLabel lTo = new JLabel("To:");
        JTextField cTo = new JTextField(32);
        JFrame frame2 = new JFrame("Compose New");
        JLabel lSubject = new JLabel("Subject");
        JTextField cSubject = new JTextField(32);
        JLabel lMessage = new JLabel("Body");
        JTextArea cMessage = new JTextArea(5,32);
        //====================================
        public EmailProg() {
            super(new BorderLayout());
            //Create the toolbar.
            JToolBar toolBar = new JToolBar();
            addButtons(toolBar);
            //Create the text area used for output.  Request
            //enough space for 5 rows and 30 columns.
            textArea = new JTextArea(5, 30);
            textArea.setEditable(false);
            textArea.setText("Welcome to Jeff's email program! With this program you can compose and send emails. I hope I get a good grade on thise, and marine world finds a good use for it :-D:-D (implements really just testing the scroller!!!)");
            JScrollPane scrollPane = new JScrollPane(textArea);
            //Lay out the main panel.
            setPreferredSize(new Dimension(450, 110));
            add(toolBar, BorderLayout.NORTH);
            add(scrollPane, BorderLayout.CENTER);
        //==================================
        protected void addButtons(JToolBar toolBar) {
            JButton button = null;
            //first button
            button = makeNavigationButton("/toolbarButtonGraphics/general/ComposeMail24.gif", composemail ,"Compose new Email", "compose new");
            toolBar.add(button);
            //second button
            button = makeNavigationButton("toolbarButtonGraphics/general/SendMail24.gif", sendmail,"Send The Mail","send");
            toolBar.add(button);
            //third button
            button = makeNavigationButton("toolbarButtonGraphics/general/About24.gif", about,"About","About");
            toolBar.add(button);
            //exit button
            button = makeNavigationButton("toolbarButtonGraphics/general/Stop24.gif", exit, "Exit", "Exit");
            toolBar.add(button);
        //===================================
        protected JButton makeNavigationButton(String imageName, String actionCommand, String toolTipText, String altText) {
            //Look for the image.
            String imgLocation = imageName;
            URL imageURL = EmailProg.class.getResource(imgLocation);
            //Create and initialize the button.
            JButton button = new JButton();
            button.setActionCommand(actionCommand);
            button.setToolTipText(toolTipText);
            button.addActionListener(this);
            if (imageURL != null) {                      //image found
                button.setIcon(new ImageIcon(imageURL));
            } else {                                     //no image found
                button.setText(altText);
                System.err.println("Resource not found: "+ imgLocation);
            return button;
        //=============================
        public void actionPerformed(ActionEvent e) {
            String cmd = e.getActionCommand();
            String description = null;
            // Handle each button.
            if (exit.equals(cmd)){
                textArea.setText("");
                description = "EXITING";
                System.exit(0);
            if (composemail.equals(cmd)) { //first button clicked
                textArea.setText("");
                description = "Write new mail.";
                composeWindow();
            } else if (sendmail.equals(cmd)) { // second button clicked
                textArea.setText("");
                description = "This button does'nt do anything yet :x";
            } else if (about.equals(cmd)) { // third button clicked
                textArea.setText("");
                description = "About this program. (See pop-up)";
                coolWindow();
            else if (submit.equals(cmd))
                if (cFrom.getText().equals("")||cTo.getText().equals("")||cSubject.getText().equals("")||cMessage.getText().equals(""))
                    textArea.setText("One or more of the fields was not filled in.");
                else{
                      try {
                                String smtpServer="serverhere";
                                String to=cTo.getText();
                                String from=cFrom.getText();
                                String subject=cSubject.getText();
                                String body=cMessage.getText();
                                send(smtpServer, to, from, subject, body);
                                textArea.setText("");
                                description = "Mail Sent.";
                                JOptionPane.showMessageDialog(null, "Message Sent.");
            catch (Exception ex)
                System.out.println("Usage: java com.lotontech.mail.SimpleSender"
                +" smtpServer toAddress fromAddress subjectText bodyText");
                    //CLOSE THE FRAME2 WINDOW IIIIIIIIFFFFFFF SENDING IS SUCCESSFUL!!
                }//end of else during send
           }//end of if of submit
            displayResult(description);
        //============================
        protected void displayResult(String actionDescription) {
            textArea.append(actionDescription + newline);
        //=============================
        public void coolWindow() {
            JFrame frame = new JFrame("About");
            JTextArea filecontents = new JTextArea();
            filecontents.setText("Use the tool bar to compose\n compose new emails, in which you can\n send to anyone on the\n srvhs email server. \n Fill in all the blanks before pressing send. If you dont\n you will receive an error! \n For more information about this program click on the\n information button.");
            frame.getContentPane().add(filecontents, BorderLayout.CENTER);
            frame.pack();
            frame.setResizable(false);
            frame.setSize(300,200);
            frame.setVisible(true);
         //===============================
        public void composeWindow() {
            frame2.getContentPane().setLayout(new GridBagLayout());
            frame2.setResizable(false);
            frame2.setSize(600,500);
            frame2.setVisible(true);
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.insets = new Insets(5, 10, 5, 10);
            cMessage.setLineWrap(true);
            subbutton = makeNavigationButton("toolbarButtonGraphics/general/SendMail24.gif", submit,"submit","submit");
            addRow(gbc, lFrom, cFrom);
            addRow(gbc, lTo, cTo);
            addRow(gbc, lSubject, cSubject);
            addRow(gbc, lMessage, cMessage);
            addRow(gbc, lSubmit, subbutton);
        //===============================
        private void addRow(GridBagConstraints gbc, Component left, Component right) {
            gbc.gridx = GridBagConstraints.RELATIVE;
            gbc.gridy = GridBagConstraints.RELATIVE;
            gbc.gridheight = 1;
            gbc.gridwidth = 1;
            gbc.anchor = GridBagConstraints.EAST;
            frame2.getContentPane().add(left, gbc);
            gbc.gridwidth = GridBagConstraints.REMAINDER;
            gbc.anchor = GridBagConstraints.WEST;
            frame2.getContentPane().add(right, gbc);
            frame2.pack();
       //=======================
        public static void send(String smtpServer, String to, String from, String subject, String body) {
        try {
          Properties props = System.getProperties();
          props.put("mail.smtp.host", smtpServer);
          Session session = Session.getDefaultInstance(props, null);
          // -- Create a new message --
          Message msg = new MimeMessage(session);
          // -- Set the FROM and TO fields --
          msg.setFrom(new InternetAddress(from));
          msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to, false));
          // -- We could include CC recipients too --
          // if (cc != null)
          // msg.setRecipients(Message.RecipientType.CC
          // ,InternetAddress.parse(cc, false));
          // -- Set the subject and body text --
          msg.setSubject(subject);
          msg.setText(body);
          // -- Set some other header information --
          msg.setHeader("X-Mailer", "LOTONtechEmail");
          msg.setSentDate(new Date());
          // -- Send the message --
          Transport.send(msg);
          System.out.println("Message sent OK.");
        catch (Exception ex)
          ex.printStackTrace();
        public static void main(String[] args) {
            JFrame frame = new JFrame("EmailProg");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            EmailProg newContentPane = new EmailProg();
            newContentPane.setOpaque(true);
            frame.setContentPane(newContentPane);
            //Display the window.
            frame.pack();
            frame.setVisible(true);
    }

  • Sending Email using cl_bcs from a badi implementation

    Hi,
    I have written my code to send Email, inside AFTER_SAVE method of BADI Implementation of DOCUMENT_MAIN01.
    Now this method of cl_bcs requires COMMIT WORK for the mail to be sent. And inside BADI implementation, we cannot write a COMMIT statement.
    What is a workaround for this? While going through few other posts, I came across remote enabled FMs.
    Is that the only way? Can I use some additions like STARTING NEW TASK etc. Following is the call used in case of cl_bcs:
       CALL METHOD G_REF_SEND_REQUEST->SEND(
              EXPORTING
                I_WITH_ERROR_SCREEN = 'X'
             RECEIVING
                RESULT              = G_SENT_TO_ALL ).
    I also tried using SO_NEW_DOCUMENT_SEND_API1 STARTING NEW TASK and it works fine. But the subject length is a constraint their.
    Please suggest.
    Thanks in advance.

    Hi friend.
    *& Report  ZTEST_273068_EMAIL_CL_BCS
    REPORT  ZTEST_273068_EMAIL_CL_BCS.
    CONSTANTS:
        gc_subject TYPE so_obj_des VALUE 'ABAP Email with CL_BCS',
        gc_raw     TYPE char03 VALUE 'RAW'.
      DATA:
        gv_mlrec         TYPE so_obj_nam,
        gv_sent_to_all   TYPE os_boolean,
        gv_email         TYPE adr6-smtp_addr,
        gv_subject       TYPE so_obj_des,
        gv_text          TYPE bcsy_text,
        gr_send_request  TYPE REF TO cl_bcs,
        gr_bcs_exception TYPE REF TO cx_bcs,
        gr_recipient     TYPE REF TO if_recipient_bcs,
        gr_sender        TYPE REF TO cl_sapuser_bcs,
        gr_document      TYPE REF TO cl_document_bcs.
      TRY.
          "Create send request
          gr_send_request = cl_bcs=>create_persistent( ).
          "Email FROM...
          gr_sender = cl_sapuser_bcs=>create( sy-uname ).
          "Add sender to send request
          CALL METHOD gr_send_request->set_sender
            EXPORTING
              i_sender = gr_sender.
          "Email TO...
          gv_email = '[email protected]'.
          gr_recipient = cl_cam_address_bcs=>create_internet_address( gv_email ).
          "Add recipient to send request
          CALL METHOD gr_send_request->add_recipient
            EXPORTING
              i_recipient = gr_recipient
              i_express   = 'X'.
          "Email BODY
          APPEND 'Hello world! My first ABAP email!' TO gv_text.
          gr_document = cl_document_bcs=>create_document(
                          i_type    = gc_raw
                          i_text    = gv_text
                          i_length  = '12'
                          i_subject = gc_subject ).
          "Add document to send request
          CALL METHOD gr_send_request->set_document( gr_document ).
          "Send email
          CALL METHOD gr_send_request->send(
            EXPORTING
              i_with_error_screen = 'X'
            RECEIVING
              result              = gv_sent_to_all ).
          IF gv_sent_to_all = 'X'.
            WRITE 'Email sent!'.
          ENDIF.
          "Commit to send email
          COMMIT WORK.
          "Exception handling
        CATCH cx_bcs INTO gr_bcs_exception.
          WRITE:
            'Error!',
            'Error type:',
            gr_bcs_exception->error_type.
      ENDTRY.
    Just Execute it.
    Regards,
    Thrimu

  • Sending email using Mail from T-Mobile Hot Spot

    I cannot send email messages from a Hot Spot using the Mail program. It says it cannot send using the server smtp.mac.com. This is the first problem I've had with this. Today is my first day using a Hot Spot. Has anyone encountered this same issue? Do I have to change some of the settings?
    I tried using the Internet based .Mac account and was able to send messages but not directly from Mail program.

    5. Does T-Mobile provide me with an email account?
    T-Mobile does not provide email accounts for its users.
    6. Can I access my personal email account through my T-Mobile HotSpot account?
    You can access any web-based email account such as Yahoo.com or Hotmail.com. You can also access corporate email accounts if your employer provides you with a virtual private network (VPN) client and a firewall. T-Mobile strongly recommends that its customers take measures to ensure the security of their wireless connections, such as virtual private networks (VPNs), encryption and firewalls. As with any wireless communication, the T-Mobile HotSpot service is not inherently secure and you should ensure you have adequate security safeguards in place. See the Hotspot Security Statement posted on our website for additional information concerning the security of the service and steps you can take to enhance the security of the service.
    http://hotspot.t-mobile.com/support_faq.htm#U1

Maybe you are looking for