Results 1 to 3 of 3
  1. #1
    learning.java is offline Member
    Join Date
    Sep 2013
    Posts
    7
    Rep Power
    0

    Default Send Automatic Email Confimaiton

    Hello, before Implement this into my real program I just made a little program to test this out. I want to have a button send an automatic email to the user if they click the button. As of right now, I have it where when the button clicks it opens up MY email (I scythed it to the emulator) and you have to click send. It does work, but It to send the email right away - no question asked. here is what I have.

    Java Code:
    public class MainActivity extends Activity {
    
    	String email = "test";
    
    	@Override
    	protected void onCreate(Bundle savedInstanceState) 
    	{
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.activity_main);
    		
    		
    	
    		LinearLayout ll = new LinearLayout(this);
    		ll.setOrientation(LinearLayout.VERTICAL);
    		ll.setGravity(Gravity.CENTER_VERTICAL);
    		
    		Button send = new Button(this);
    		
    		send.setGravity(Gravity.CENTER_HORIZONTAL);
    		send.setGravity(Gravity.CENTER_VERTICAL);
    		
    		send.setOnClickListener(buttonListener);
    		
    		send.setId(1);
    		
    		ll.addView(send);
    		
    		setContentView(ll);
    		
    		
    		
    	}
    
    
    	
    	private OnClickListener buttonListener = new OnClickListener() 
      	{
      		public void onClick(View v) 
      		{   
      			
      			Intent i = new Intent(Intent.ACTION_SEND);
      			//i.setType("message/rfc822");
      			i.putExtra(Intent.EXTRA_EMAIL  , new String[]{"anyemail@gmail.com"});
      			i.putExtra(Intent.EXTRA_SUBJECT, "subject of email");
      			i.putExtra(Intent.EXTRA_TEXT   , "body of email");
      			
      			
      			
      			
      			/*
      			Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
      			emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, email );
      			startActivity(Intent.createChooser(emailIntent, "Send someone an email..."));
      			*/
      			
      			try {
      			    startActivity(Intent.createChooser(i, "Send mail..."));
      			} catch (android.content.ActivityNotFoundException ex) {
      			    Toast.makeText(MainActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
      			}
      			
      		
      		}
      		
      	};

  2. #2
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,058
    Rep Power
    5

    Default Re: Send Automatic Email Confimaiton

    In J2SE, the standard answer was 'javamail'. In Android, there's this: javamail-android - JavaMail port for the android plateform - Google Project Hosting I can't vouch for it, but you could give it a try.
    Get in the habit of using standard Java naming conventions!

  3. #3
    learning.java is offline Member
    Join Date
    Sep 2013
    Posts
    7
    Rep Power
    0

    Default Re: Send Automatic Email Confimaiton

    Thanks, I'll give it a shot!

Similar Threads

  1. Replies: 10
    Last Post: 06-06-2010, 06:49 PM
  2. automatic email
    By pracheebapate in forum New To Java
    Replies: 2
    Last Post: 01-18-2009, 08:07 PM
  3. send email using JMS
    By Heather in forum Advanced Java
    Replies: 9
    Last Post: 01-07-2009, 03:04 PM
  4. automatic email
    By aswin in forum New To Java
    Replies: 0
    Last Post: 11-13-2008, 08:03 AM
  5. send email using apache commons email
    By jnamendi in forum JavaServer Faces (JSF)
    Replies: 0
    Last Post: 10-14-2008, 05:55 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •