Sending email without inbuilt gmail app also with attachment i need full code with attachment plzzz
Sending email without inbuilt gmail app also with attachment
160901-Dec-2017
Updated on 02-Jul-2023
Home / DeveloperSection / Forums / Sending email without inbuilt gmail app also with attachment
Sending email without inbuilt gmail app also with attachment i need full code with attachment plzzz
Aryan Kumar
02-Jul-2023Sure, here is how to send an email without the inbuilt Gmail app and with an attachment in Android:
Code snippet
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. TheEXTRA_SUBJECT
extra is used to set the subject of the email. TheEXTRA_TEXT
extra is used to set the body of the email. TheEXTRA_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'sonCreate()
method.Here is an example of how you could call the
sendEmail()
method in your app'sonCreate()
method:Code snippet
When you run the app, the default email app on the device will be started and the email will be sent.