RBS
RBS

Reputation: 269

Is there any way to send mail automatically from an application?

I have created an application that gets the location information(latitude,longitude,altitude) and sends email using ACTION_SEND to some gmail account. But i am unable to send auto generated mail to that account. I need to send mail whenever the location changes. But my application is displaying the list of choosers available. Please give me some idea.

Upvotes: 1

Views: 203

Answers (1)

Praveenkumar
Praveenkumar

Reputation: 24496

From you case, you need to send mail when your location has been changed right. So, you've onLocationChanged from you class. From, there you can use this example for sending mail.

For example,

public void onLocationChanged(Location loc)
{
    // Call the GmailSender as per the example
    try {   
        GMailSender sender = new GMailSender("[email protected]", "password");
        sender.sendMail("This is Subject",   
                        "This is Body",   
                        "[email protected]",   
                        "[email protected]");   
        } catch (Exception e) {   
            Log.e("SendMail", e.getMessage(), e);   
        }
}

So, you can simply send the mail when your location will changed instead of sending mail through Button click.

Upvotes: 1

Related Questions