---
title: "Sending email without inbuilt gmail app also with attachment"  
description: "Sending email without inbuilt gmail app also with attachment"  
author: "Maharshi Tech8"  
published: 2017-12-01  
updated: 2023-07-02  
canonical: https://www.mindstick.com/forum/34371/sending-email-without-inbuilt-gmail-app-also-with-attachment  
category: "android apps"  
tags: ["android"]  
reading_time: 2 minutes  

---

# Sending email without inbuilt gmail app also with attachment

[Sending email](https://www.mindstick.com/forum/134/problem-sending-email-in-asp-dot-net) without inbuilt [gmail](https://www.mindstick.com/articles/157262/why-to-go-with-the-gmail-signup-procedure) app also with attachment i need [full](https://www.mindstick.com/articles/12893/experience-the-full-power-of-suitecrm) [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) with attachment plzzz

## Replies

### Reply by Aryan Kumar

Sure, here is how to send an [email](https://www.mindstick.com/articles/12870/10-easy-ways-to-manage-your-business-email-inbox) without the inbuilt Gmail app and with an attachment in Android:

Code snippet

```plaintext
public void sendEmail(String[] recipients, String subject, String body, Uri attachment) {
    // Create an intent to send an email
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("message/rfc822");

    // Set the recipients
    intent.putExtra(Intent.EXTRA_EMAIL, recipients);

    // Set the subject
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);

    // Set the body
    intent.putExtra(Intent.EXTRA_TEXT, body);

    // Set the attachment
    if (attachment != null) {
        intent.putExtra(Intent.EXTRA_STREAM, attachment);
    }

    // Start the activity to send the email
    startActivity(intent);
}
```

This code will first create an intent to send an email. The intent will be set to send a `message/rfc822` type of email.

The `putExtra()` method is used to set the values of the intent's extras. The extras are key-value pairs that are used to pass data to the activity that is started by the intent.

The `EXTRA_EMAIL` extra is used to set the recipients of the email. The `EXTRA_SUBJECT` extra is used to set the subject of the email. The `EXTRA_TEXT` extra is used to set the body of the email. The `EXTRA_STREAM` extra is used to set the attachment of the email.

The `startActivity()` method is used to start the activity to send the email. The activity that is started will be the default email app on the device.

To use this code, you would need to call the `sendEmail()` method in your app. For example, you could call the method in your app's `onCreate()` method.

Here is an example of how you could call the `sendEmail()` method in your app's `onCreate()` method:

Code snippet

```plaintext
public void onCreate() {
    super.onCreate();

    // Get the recipients
    String[] recipients = {"recipient1@example.com", "recipient2@example.com"};

    // Get the subject
    String subject = "This is an email";

    // Get the body
    String body = "This is the body of the email";

    // Get the attachment
    Uri attachment = Uri.parse("path/to/attachment.jpg");

    // Send the email
    sendEmail(recipients, subject, body, attachment);
}
```

When you run the app, the default email app on the device will be started and the email will be sent.


---

Original Source: https://www.mindstick.com/forum/34371/sending-email-without-inbuilt-gmail-app-also-with-attachment

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
