简体   繁体   中英

Triggering email from a specific email account in android

Hi I am developing an android application in which a form has to be submitted over email. my code is as follows

Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_EMAIL  , new String[]{"mail id"});
i.putExtra(Intent.EXTRA_SUBJECT, "Subjec");
i.putExtra(Intent.EXTRA_TEXT  ,"Hi"
startActivity(i);

When I click submit on the form it is triggering a spinner from which user has to select email to goto email. The problem it is showing hell lot of other unnecessary options such as bluetooth, colornote etc... I want only email or gmail to be shown or a better way it should directly goto email application

Please kindly give me your valuable advice.

Thanking you Yours sincerely Chinnikrishna

Option #1: Use ACTION_SENDTO as seen here and here .

Option #2: Use message/rfc822 instead of text/plain (and format your message accordingly) as seen here .

Neither are guaranteed to only give you mail clients, though the first option is likely to only be mail clients.

Hi I found the answer to my question I need to add

i.setType("application/octet-stream");

Then it is giving me only gmail and email :-)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM