Android Send Email not present in email client sent - android

When I try to send an email (for example with gmail client) via INTENT, in my email client I don't see the email sent. The code is:
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_EMAIL, new String[] { to });
email.putExtra(Intent.EXTRA_SUBJECT, subject);
email.putExtra(Intent.EXTRA_TEXT, message);
email.setType("application/zip");
email.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(pathZipCryptDestination)));
email.setType("message/rfc822");
activity.startActivity(Intent.createChooser(email, "E-Mail:"));
The email arrives but I don't see it in email sent.
I must set some parameter?

What client are you exactly using?
Basically all you do is pass some data to the other app, which uses this.
It has little to do with your own app, as the other app takes over and completes sending the email. If somehow they do not do this properly and thus your email is not added to your 'send emails' that sounds more like a problem in their app and out of your hands.

Related

how can i send email from my application using registered Android email without password

I want to send some text from my application to custom email address
i need to use email which is registered on device
i try many examples which is using email and password ,or using Intent , but it's not correct for me
So how can i do this, which will looks something like this
Use below code that will ask the user to open and Email Client for sending the email -
String to = "sarkerpt#gmail.com";
String subject = "Barcode Reader For Android - Bug Report";
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_EMAIL, new String[]{to});
email.putExtra(Intent.EXTRA_SUBJECT, subject);
email.setType("message/rfc822");
startActivity(Intent.createChooser(email, "Choose an Email client :"));

android ACTION_SENDTO creates email doesn't send it

Have working code that 1) opens an email client on an android device and 2) successfully populates all the fields needed to send a message. This includes the to, from, subject and message body.
e String mailMsg = "mailto:elmer#gmail.com" +
"?cc="+"" + //needed to fill out email properly
"&subject=" + Uri.encode(subject) +
"&body=" + Uri.encode(emailBody);
Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
emailIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
emailIntent.setData(Uri.parse(mailMsg));
try{
context.startActivity(emailIntent);
}catch (ActivityNotFoundException ae){
Log.d("TEST100 ","Error sending email");
}
Again the code works fine in terms of opening the email client, creating an populating the email message but, it does not send the email. Could it be because I have multiple email providers? The code always manages to connect to and work with my mai based provider.
Have read the google documentation and most relevant posts in stackoverflow, is it possible to:
1. trigger the sending of the email message without user involvement?
2. mask the display/process of creating the email?
Any information appreciated
is it possible to: trigger the sending of the email message without user involvement?
Fortunately, no.
mask the display/process of creating the email?
Fortunately, no.
Malware authors, spammers, and the like would love to have the ability to send an email, without user involvement, using the user's own email account. Most users would find this behavior to be inappropriate.
If you want to send an email without user involvement, have your Web service send the email on your behalf, using your own email account and your own mail server.

Send mail with javamail without user and password

I followed this post Sending Email in Android using JavaMail API without using the default/built-in app to send mails without intents. it works ok. but my question is if you can send mail without having to enter your user and password? thanks
No you can't
As you can see from the code, The username and password is used to login to that mail ID and then that Email ID is used to send the Email
The GMailSender has a constructor that takes in the username and password, this is used to create a login session as in code
session = Session.getDefaultInstance(props, this);
Once the login has been done now your sending the Email from that mail ID as you normally do in browser
Alternatives
Now if you want to send a email then you can send an intent in android like this
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_EMAIL, new String[]{"youremail#gmail.com"});
email.putExtra(Intent.EXTRA_SUBJECT, "subject");
email.putExtra(Intent.EXTRA_TEXT, "message");
email.setType("message/rfc822");
startActivity(Intent.createChooser(email, "Choose an Email client"));
But this would pop up the user with the choice of client from which email has to be sent
OR
If you even dont want to use this, then I would suggest creating your own webserver and make HTTP request to it to send Emails via the server

Simple mail sender

Earlier I was using an intent to complete this operation:
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_EMAIL, new String[]{"xxxxxxx#gmail.com"});
email.putExtra(Intent.EXTRA_TEXT, "");
email.setType("message/rfc822");
try{
startActivity(Intent.createChooser(email, "Feedback to TFC"));
}catch(android.content.ActivityNotFoundException e)
{
Toast.makeText(getApplicationContext(), "There are no email clients installed", Toast.LENGTH_SHORT).show();
}
But then again the intent results in a form with the address, subject and the message. For now I only want the message part. I did have a look at this blog . Is it necessary to give the username and password ?? Is there no simple mailto: function in android as we see in html so that the message is just sent without me having to use the all the complicated functions ?
You can refer to https://stackoverflow.com/a/2033124/1051147 which explains how to Send e-mail in Android using the JavaMail API using Gmail authentication
note that you will need some additional jar for getting it done. As i explained the simplest method is to use intent.

It is possible to hide the destination email address?

In my app I have an option, "Contact us", but anyway, I would like that the user to not see the email address where they send the email. I use the standard way to send the email, but however I build the interface, when the Email Client starts the destination email is shown.
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL , new String[]{"myemail#gmail.com"});
i.putExtra(Intent.EXTRA_SUBJECT, "Subject");
//i.putExtra(Intent.EXTRA_TEXT , "emailBody");
try {
startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(SecondActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}
I would like that myemail#gmail.com to be undisclosed to users.
Over the internet we find this in many cases, where just a button "Send" is provided, for example, but how could we do this on Android?
I would like that myemail#gmail.com to be undisclosed to users.
If you wish to use ACTION_SEND, the user has the right to know the content they are sending and the email address they are sending it to, and to modify any of that as they see fit. It is their device, their email account doing the sending, and their bandwidth that is being consumed.
Over the internet we find this in many cases, where just a button "Send" is provided
The Web server is sending the email, rather than asking the user's browser to send the email.
how could we do this on Android?
You are welcome to find a JavaMail port for Android, or an equivalent library, and send the email directly yourself. Of course, you will need to configure your app to know an SMTP relay that you can use to do the sending.

Categories

Resources