Advertisement
Guest User

Untitled

a guest
Jul 20th, 2015
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. startActivity(new Intent(anotherClass.this, SendMail.class));
  2.  
  3. public void loginAs()
  4. {
  5. SendMail class2 = new SendMail();
  6. class2.doSomething();
  7. }
  8.  
  9. public static void doSomething() {
  10. SendMail.main(new String[] {"main"});
  11. }
  12.  
  13. "Oops something has gone pearshaped!"
  14.  
  15. 07-20 16:32:29.507 11953-11953/seatme.camaleonpos.com.seatme I/System.out﹕ android.os.NetworkOnMainThreadException
  16.  
  17. import...
  18.  
  19. public class SendMail extends Object {
  20.  
  21. public static void doSomething(String sUser, String sPass) {
  22. SendMail.main(new String[] {"main"})
  23. }
  24.  
  25. public static void main(String [] args)
  26. {
  27. for (String s : args)
  28. System.out.println(s);
  29. try{
  30. Properties props = new Properties();
  31. props.put("mail.smtp.host", "smtp.gmail.com"); // for gmail use smtp.gmail.com
  32. props.put("mail.smtp.auth", "true");
  33. props.put("mail.debug", "true");
  34. props.put("mail.smtp.starttls.enable", "true");
  35. props.put("mail.smtp.port", "465");
  36. props.put("mail.smtp.socketFactory.port", "465");
  37. props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
  38. props.put("mail.smtp.socketFactory.fallback", "false");
  39. Session mailSession = Session.getInstance(props, new javax.mail.Authenticator() {
  40. protected PasswordAuthentication getPasswordAuthentication() {
  41. return new PasswordAuthentication("foo@gmail.com", "foo"); } });
  42. mailSession.setDebug(true); // Enable the debug mode
  43. Message msg = new MimeMessage( mailSession );
  44. //--[ Set the FROM, TO, DATE and SUBJECT fields
  45. msg.setFrom( new InternetAddress( "foo@gmail.com " ) );
  46. msg.setRecipients( Message.RecipientType.TO,InternetAddress.parse("1111111111@messaging.sprintpcs.com") );
  47. msg.setSentDate( new Date());
  48. msg.setSubject( "Hello World!" );
  49. //--[ Create the body of the mail
  50. msg.setText( "Hello from my first e-mail sent with JavaMail" );
  51. //--[ Ask the Transport class to send our mail message
  52. Transport.send( msg );
  53. }catch(Exception E){
  54. System.out.println( "Oops something has gone pearshaped!");
  55. System.out.println( E );
  56. return;
  57. }
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement