Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- startActivity(new Intent(anotherClass.this, SendMail.class));
- public void loginAs()
- {
- SendMail class2 = new SendMail();
- class2.doSomething();
- }
- public static void doSomething() {
- SendMail.main(new String[] {"main"});
- }
- "Oops something has gone pearshaped!"
- 07-20 16:32:29.507 11953-11953/seatme.camaleonpos.com.seatme I/System.out﹕ android.os.NetworkOnMainThreadException
- import...
- public class SendMail extends Object {
- public static void doSomething(String sUser, String sPass) {
- SendMail.main(new String[] {"main"})
- }
- public static void main(String [] args)
- {
- for (String s : args)
- System.out.println(s);
- try{
- Properties props = new Properties();
- props.put("mail.smtp.host", "smtp.gmail.com"); // for gmail use smtp.gmail.com
- props.put("mail.smtp.auth", "true");
- props.put("mail.debug", "true");
- props.put("mail.smtp.starttls.enable", "true");
- props.put("mail.smtp.port", "465");
- props.put("mail.smtp.socketFactory.port", "465");
- props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
- props.put("mail.smtp.socketFactory.fallback", "false");
- Session mailSession = Session.getInstance(props, new javax.mail.Authenticator() {
- protected PasswordAuthentication getPasswordAuthentication() {
- return new PasswordAuthentication("foo@gmail.com", "foo"); } });
- mailSession.setDebug(true); // Enable the debug mode
- Message msg = new MimeMessage( mailSession );
- //--[ Set the FROM, TO, DATE and SUBJECT fields
- msg.setFrom( new InternetAddress( "foo@gmail.com " ) );
- msg.setRecipients( Message.RecipientType.TO,InternetAddress.parse("1111111111@messaging.sprintpcs.com") );
- msg.setSentDate( new Date());
- msg.setSubject( "Hello World!" );
- //--[ Create the body of the mail
- msg.setText( "Hello from my first e-mail sent with JavaMail" );
- //--[ Ask the Transport class to send our mail message
- Transport.send( msg );
- }catch(Exception E){
- System.out.println( "Oops something has gone pearshaped!");
- System.out.println( E );
- return;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement