Download presentation
Presentation is loading. Please wait.
Published byRoderick Shelton Modified over 9 years ago
1
Android and Emails Ken Nguyen Clayton state University 2012
2
Sending Emails There are two main methods to send an email – Via email clients such as gmail or similar clients – Via SMTP/IMAP or similar services – auto emailing Using email client required the user have their email account already setup Using the SMTP/IMAP or other service required the service properly configured – look at javax.mail package
3
Sending emails via gmail client // EmailMainActivity.java public class EmailMainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_email_main); Button send=(Button) findViewById(R.id.buttonSend); //send an email when the button is click send.setOnClickListener(new OnClickListener() { public void onClick(View v) { final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("plain/text"); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{ “email@address.com"});
4
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Your email subject"); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Your email message"); EmailMainActivity.this.startActivity(Intent.createChooser(emailIntent, "Send mail... – notification while sending")); } }); }
5
Layout.xml <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/LinearLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <Button android:id="@+id/buttonSend" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="send email" />
6
Exercise Create a registration activity where the user can enter their contact information and an email will be sent to them as a confirmation
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.