0

Please Help! I'm kinda new to android but I am trying to create an app with a simple form that consists of a name field an email field and a send button. When the button is clicked, I need it to send their name and email address to my email address. Is this possible? I'm not trying to have them open up an email client on the device but just to be able to click the button once send their name and email to my email kinda like website forms.

Here is my java code (Sorry if its kinda hard to read)

package com.mail;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

public class Mail extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

    }
        public void sendFeedback(View button) {  
                    // Do click handling here  

           final EditText nameField = (EditText) findViewById(R.id.EditTextName);  
          String name = nameField.getText().toString();  

          final EditText emailField = (EditText) findViewById(R.id.EditTextEmail);  
          String email = emailField.getText().toString(); 

    }
}
Nate
  • 16,748
  • 5
  • 45
  • 59
user684495
  • 1
  • 1
  • 1
  • 3
    Screaming, "Please help!" isn't going to make anyone answer faster. It's just rude. – HardCode Mar 30 '11 at 18:26
  • Possible duplicate of [How can I send emails from my Android application?](http://stackoverflow.com/questions/2197741/how-can-i-send-emails-from-my-android-application) – Nick Volynkin Mar 14 '17 at 03:25

2 Answers2

2

If you want to send the email through an email app installed on the device you can use the process described in the "how to send email from my android application" question.

However, it sounds like you want to send the email without any user interaction with an email app.

You could make "a website form that sends email" like you mentioned in your question, and invoke the form's action URL with parameters built from your two fields using Android's HttpClient class.

If you want to build and send the email from the Android app itself, and not rely on separate code on a web server, you'll want to use something like JavaMail inside your app. Here's a blog post with code and links to an Android compatible version of JavaMail.

Community
  • 1
  • 1
Nate
  • 16,748
  • 5
  • 45
  • 59
0

You cannot send an email on behalf of the user wihtout the user explicitly agreeing to it. What you can do though is to send that data to a Google docs spreadsheet and then have the Google sheet send you a notification on gmail every time someone sends data. This article details how to send data from android app to Google docs sheet.

Sourabh86
  • 744
  • 10
  • 18