简体   繁体   中英

how to send mail to an email id in android?

In my project i have to send mail to company id.First i tried code with my email id. but its not showing anything.my code is here

Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);        
String aEmailList[] = { "my emailid used here" };  
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, aEmailList); 
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "My subject"); 
emailIntent.setType("plain/text");  
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "My message body.");       
startActivity(emailIntent);
Log.e("name","msg sent success fully");

in my logcat i saw "msg sent success fully" message also. but i didnt get any mail in my mail id. am i did any wrong code or am i need to add any permissions in manifest file.

Your code seems fine except there is no need to use "android.content." and there is no FLAG_ACTIVITY_NEW_TASK What should happen is that your email program should start with these data already entered. Have you setup your email client on that device?

Here is a code example that works and sends an image selected from a gallery as an attachment:

Intent i = new Intent(Intent.ACTION_SEND);  
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);  
i.setType("image/png");  
i.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + mUrls[imageSelected].toString()));  
startActivity(i); 

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