Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- protected String doInBackground(Void... params) {
- try {
- GMailSender sender = new GMailSender("xxxx@gmail.com",
- "xxxxpassword");
- sender.sendMail("This is a testing mail",
- "This is Body of testing
- mail","oskr.developer1024@gmail.com",
- "oskr.developer1024@gmail.com") ;
- } catch (Exception e) {
- Log.e("error", e.getMessage(), e);
- return "Email No Enviado";
- }
- return "Email Enviado";
- }
- @Override
- protected void onPostExecute(String result) {
- Log.e("LongOperation",result+"");
- }
- @Override
- protected void onPreExecute() {
- }
- @Override
- protected void onProgressUpdate(Void... values) {
- }
- }
- String emailAccount = "";
- AccountManager accountManager = AccountManager.get(getApplicationContext());
- Account account = getAccount(accountManager);
- if (account != null) {
- emailAccount = account.name;
- }
- private static Account getAccount(AccountManager accountManager) {
- Account[] accounts = accountManager.getAccountsByType("com.google");
- Account account;
- if (accounts.length > 0) {
- account = accounts[0];
- } else {
- account = null;
- }
- return account;
- }
Add Comment
Please, Sign In to add comment