how to send email from your android app using intent
MainActivity.java
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.Uri;
import android.os.Bundle;
import android.view.Gravity;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// open gmail through intent
openGmail(new String[]{"infojkasdkad@gmail.com", "hassfajsf@gmail.com"}, "Type Subject", "This is email body");
}
private void openGmail(String[] emailIds, String subject, String body) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_EMAIL, emailIds);
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
intent.putExtra(Intent.EXTRA_TEXT, body);
intent.setType("message/rfc822");
intent.setPackage("com.google.android.gm");
startActivity(intent);
}
Projects with Source Code + Video Tutorials
You can download our Java and Android Studio Projects with Source Code and Video Tutorials.
Firebase Push Notifications | Background Notification
Spin and Win App for Android (Offline Version)
How to create custom Update Dialog with Example in Android Studio
If you have any Questions or Queries
You can mail us at info.learnoset@gmail.com
Follow us to learn Coding and get in touch with new Technologies.