Created
May 29, 2020 06:46
-
-
Save KryptKode/ed47d3eaeb40e2a86d286c1040a19458 to your computer and use it in GitHub Desktop.
Helper for sending email android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.app.Activity | |
import android.content.Intent | |
import android.net.Uri | |
import androidx.appcompat.app.AppCompatActivity | |
import com.kryptkode.flashalerts.R | |
import javax.inject.Inject | |
/** | |
* Created by kryptkode on 2/26/2020. | |
*/ | |
class SendEmailUtil @Inject constructor(private val activity: AppCompatActivity) { | |
fun sendEmail(recipientEmail: String, subject: String, body: String) { | |
val intent = Intent( | |
Intent.ACTION_SENDTO, Uri.fromParts( | |
"mailto", recipientEmail, null | |
) | |
) | |
intent.putExtra(Intent.EXTRA_EMAIL, arrayOf(recipientEmail)) | |
intent.putExtra(Intent.EXTRA_SUBJECT, subject) | |
intent.putExtra(Intent.EXTRA_TEXT, body) | |
activity.startActivity( | |
Intent.createChooser( | |
intent, | |
activity.getString(R.string.send_email_hint) | |
) | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment