1 / 6

Android and Emails

Android and Emails. Ken Nguyen Clayton state University 2012. 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

Download Presentation

Android and Emails

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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 <LinearLayoutxmlns: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" /> </LinearLayout>

  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

More Related