Connecting directly to GMAIL with android [duplicate]

独自空忆成欢 提交于 2019-12-20 05:46:21

问题


Possible Duplicate:
Sending Email in Android using JavaMail API without using the default/built-in app

I want to send an email with an attached audio file over gmail that i record with my application. Can I send a direct mail from android with attachment without getting the options to choose the method of sending? (bluetooth,etc etc ) ? I just want to send the mail with the attachment on the click of a button.

Can I do this with android? Also, i would be obliged is I could get the code for sending mail over gmail with android.


回答1:


here is a complete example which sends a background email (using gmail account) to others, ofcourse with attachment. Send email with attachment using GMAIL account.

Find an example project here in this project you need to set the following gmail account details in MailSenderActivity class

private static final String GMAIL_EMAIL_ID = "";
private static final String GMAIL_ACCOUNT_PASSWORD = "";
private static final String TO_ADDRESSES = ""; // to email addresses separated by comma

If you don't need the ZipUtility class, remove that and use it according to your need




回答2:


unfortunately, there is no way to force the user to choose the Gmail app instead of the built in mail client.

most users already have a gmail account if they own an android client so they'll probably use it anyway.




回答3:


As others have already posted you can use the java mail api, BUT you'd have to hardcode your email and password which isn't something advisable.

What you can do is connect to a webservice that can send emails and use it instead. That way you reduce your security risks.



来源:https://stackoverflow.com/questions/11340023/connecting-directly-to-gmail-with-android

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!