Can't add email signature in Android - android

I'm trying to compose and send an email which will include a signature at the bottom
of my email content in android. I'm able to send an email but I'm not getting the way that allows me to add my own signature. Do you have any suggestion?
here's my code:
public void addListener() {
final Button button = (Button) findViewById(R.id.button1);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
findViewById = (TextView) findViewById(R.id.t1);
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_EMAIL,
new String[] { "some#gmail.com"});
/*i.putExtra(Intent.EXTRA_CC,
new String[] { "some#gmail.com" });*/
i.putExtra(Intent.EXTRA_SUBJECT, "Android Test");
i.putExtra(Intent.EXTRA_TEXT, "Body");
//i.putExtra(Intent.EXTRA_TEXT, "signature");
try {
startActivity(Intent.createChooser(i, "Choose mail app..."));
} catch (android.content.ActivityNotFoundException ex) {
}
}
});
}

I don't think the "signature" is really a different section of an email. I think you can just append your signature to your body.
i.putExtra(Intent.EXTRA_TEXT, "Body" + "\\n" + "Signature");

Related

Sending an email with android not sending one

I am trying to send an email to a user with Android which will include a code. For whatever reason, it does not work.
I have followed this tutorial
What is the problem?
This is the code:
public class PWReset extends AppCompatActivity {
EditText getMail;
Button Continue;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_pwreset);
getMail=findViewById(R.id.Mail);
Continue=findViewById(R.id.PWR2);
Continue.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
final String Code = UUID.randomUUID().toString().substring(0, 5);
//After checking if the email is registered in the DB
resetPassword(getMail.getText().toString(), Code);
Intent intent = new Intent(PWReset.this, PWReset2.class);
intent.putExtra("code", Code);
startActivity(intent);
}
});
}
public void resetPassword(String Mail, String code){
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_EMAIL, new String[]{getMail.getText().toString()});
email.putExtra(Intent.EXTRA_SUBJECT, "Password reset");
email.putExtra(Intent.EXTRA_TEXT, "You have requested a password reset.\nHere is the code for resetting your password:" + code +
"\nIf you have not requested a password reset, ignore this message.");
email.setType("message/rfc822");
startActivity(Intent.createChooser(email, "gmail"));
}
}

Android : Send feedback to default email [duplicate]

This question already has answers here:
Sending Email in Android using JavaMail API without using the default/built-in app
(25 answers)
Closed 6 years ago.
I've a feedback form and buttons for send and cancel. How can I make the feedback send responds to a default email when the send button is clicked? And how can I set a the default email. Is this possible? Please let me know. Thank you.
Here's is my java for the feedback form :
#Override
public void onClick(View arg0) {
// Create custom dialog object
final Dialog dialog = new Dialog(MainActivity.this);
// Include dialog.xml file
dialog.setContentView(R.layout.activity_main);
// Set dialog title
dialog.setTitle("Feedback");
dialog.show();
Button button1 = (Button) dialog.findViewById(R.id.button1);
// if decline button is clicked, close the custom dialog
button1.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// Close dialog
dialog.dismiss();
}
});
Button button2 = (Button) dialog.findViewById(R.id.button2);
// if decline button is clicked, close the custom dialog
button2.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// Close dialog
dialog.dismiss();
}
});
Open your email client programatically using a chooser:
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("plain/text");
intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "some#email.address" });
intent.putExtra(Intent.EXTRA_SUBJECT, "subject");
intent.putExtra(Intent.EXTRA_TEXT, "mail body");
startActivity(Intent.createChooser(intent, ""));
To send email programatically without using chooser,you can use this link.
You can use following snippet:
private void sendEmail(String email) {
Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
String aEmailList[] = {email};
emailIntent.setData(Uri.parse("mailto:")); // only email apps should handle this
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, aEmailList);
String feedback_msg = getString(R.string.feedback_msg);
emailIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml("<i><font color='your color'>" + feedback_msg + "</font></i>"));
emailIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.feedback_msg));
PackageManager packageManager = getActivity().getPackageManager();
boolean isIntentSafe = emailIntent.resolveActivity(packageManager) != null;
if (isIntentSafe) {
startActivity(emailIntent);
} else {
Toast.makeText(getActivity(), R.string.email_app_not_installed, Toast.LENGTH_SHORT).show();
}
}
}

How can I share text in what's app on particular Number

Using this code only open particulat number's chat but Text is not share.How can I do this?
public class MainActivity extends AppCompatActivity {
Button Wa;
String id = "+919000000000";
EditText txt;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
txt = (EditText)findViewById(R.id.editText);
Wa = (Button)findViewById(R.id.btn_whatsapp);
Wa.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Uri uri = Uri.parse("smsto:" + id);
Intent waIntent = new Intent(Intent.ACTION_SENDTO,uri);
String text = "testing message";
waIntent.setPackage("com.whatsapp");
if (waIntent != null) {
waIntent.putExtra(Intent.EXTRA_TEXT, text);
startActivity(Intent.createChooser(waIntent, text));
} else {
Toast.makeText(getApplicationContext(), "WhatsApp not found", Toast.LENGTH_SHORT)
.show();
}
}
});
}
Since you trying to achieve it as "smsto:", "text/plain" as type will help you. Try Extra as "sms_body" if it won't help.
Uri uri = Uri.parse("smsto:" + id);
Intent waIntent = new Intent(Intent.ACTION_SENDTO,uri);
String text = "testing message";
waIntent.setPackage("com.whatsapp");
if (waIntent != null) {
waIntent.setType("text/plain");
//waIntent.putExtra(Intent.EXTRA_TEXT, text);
waIntent.putExtra("sms_body", text);
startActivity(Intent.createChooser(waIntent, text));
} else {
Toast.makeText(getApplicationContext(), "WhatsApp not found", Toast.LENGTH_SHORT)
.show();
}
Please go through this stackoverflow links
Sending message through WhatsApp
Send text to specific contact
It seems that WhatsApp still does't have supported this fetaure.
You can only open chat history for particular number using below code
try {
Uri mUri = Uri.parse("smsto:+98xxxxxxxx");
Intent mIntent = new Intent(Intent.ACTION_SENDTO, mUri);
mIntent.setPackage("com.whatsapp");
// mIntent.putExtra("sms_body", "My body");
mIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
startActivity(mIntent);
} catch (Exception e) {
// alert WhatsApp in not installed
}
Answer from Here
Earlier it wasn't possible but since the May '15 update. Checkout :
try{
PackageInfo info = pm.getPackageInfo("com.whatsapp", PackageManager.GET_META_DATA);
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
String sendString = "some random string";
sendIntent.setPackage("com.whatsapp");
sendIntent.putExtra(Intent.EXTRA_TEXT, sendString);
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
sendIntent.setType("image/*");
startActivity(sendIntent);
} catch (Exception e){
// some code
}
Here PackageInfo line is just to check if WhatsApp is installed. It throws Exception if not. You can just ignore that if you want to do a normal share (and setPackage also).
Also. It is important that the media you want to share has to be publicly available on local storage.
UPDATE
To send to a specific contact
Uri uri = Uri.parse("smsto:" + "<CONTACT_NUMBER>");
Intent i = new Intent(Intent.ACTION_SENDTO, uri);
i.putExtra(Intent.EXTRA_TEXT, whatsAppMessage);
As Action Send To is now allowed.
Try something like this:
public class MainActivity extends AppCompatActivity {
Button Wa;
String id = "+919000000000";
EditText txt;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
txt = (EditText)findViewById(R.id.editText);
Wa = (Button)findViewById(R.id.btn_whatsapp);
Wa.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
PackageManager pm=getPackageManager();
try {
Uri uri = Uri.parse("smsto:" + number);
Intent i = new Intent(Intent.ACTION_SENDTO, uri);
waIntent.setType("text/plain");
String text = "testing message";
PackageInfo info=pm.getPackageInfo("com.whatsapp", PackageManager.GET_META_DATA);
waIntent.setPackage("com.whatsapp");
waIntent.putExtra(Intent.EXTRA_TEXT, text);
startActivity(Intent.createChooser(waIntent, text));
}
catch (NameNotFoundException e) {
Toast.makeText(this, "WhatsApp not found", Toast.LENGTH_SHORT).show();
}
}
});
}
}

How can ImageView link to a email?

Is it possible to make an imageview link to the email app? Like when you click it the email app will open with a specific email address to send?
findViewById(R.id.imageview).setOnClickListener(new OnClickListener() {
public void onClick(View _) {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.fromParts("mailto","abc#gmail.com", null));
startActivity(i);
}
}
img.setOnClickListener(
new OnClickListener(View v) {
String yourMail = "mail#example.com";
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("message/rfc822");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{yourMail});
intent.putExtra(Intent.EXTRA_SUBJECT, "Your subject");
intent.putExtra(Intent.EXTRA_TEXT, "Your content");
try {
startActivity(intent, "Pick an email application...");
} catch(Exception e) {
Toast.makeText(YourMainActivity.this, "Have no email application!", Toast.LENGTH_SHORT).show();
}
}
);

sending email in android

public class AndroidEmailActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final EditText edittextEmailAddress = (EditText) findViewById(R.id.email_address);
final EditText edittextEmailSubject = (EditText) findViewById(R.id.email_subject);
final EditText edittextEmailText = (EditText) findViewById(R.id.email_text);
Button buttonSendEmail_intent = (Button) findViewById(R.id.sendemail_intent);
buttonSendEmail_intent.setOnClickListener(new Button.OnClickListener() {
#Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
String emailAddress = edittextEmailAddress.getText().toString();
String emailSubject = edittextEmailSubject.getText().toString();
String emailText = edittextEmailText.getText().toString();
String emailAddressList[] = { emailAddress };
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("plain/text");
intent.putExtra(Intent.EXTRA_EMAIL, emailAddressList);
intent.putExtra(Intent.EXTRA_SUBJECT, emailSubject);
intent.putExtra(Intent.EXTRA_TEXT, emailText);
startActivity(Intent.createChooser(intent,
"Choice App t send email:"));
}
});
}
}
This is my code.I am not getting any emails.I need to send emails through this intent method.how can I acheive that?Where I went wrong?pls give some suggestions.
I am getting the error when I click the Send email button as "No applications can perform this action."
This is my code to send emails:
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, activity.getString(R.string.share_email_subject));
sendIntent.setType("message/rfc822");
activity.startActivity(Intent.createChooser(sendIntent, "Choose Email Client"));
Try removing the plain/text type?
It is Good practice to work with original device rather than on Virtual Device. I suggest you try this code block on real device.
Intent sendEmail= new Intent(Intent.ACTION_SEND);
sendEmail.setType("plain/text");
startActivity(Intent.createChooser(sendEmail, "Email:"));
If you want to see more on Email with Intent then refer to this post:
http://androidtutforbeginner.blogspot.com/2012/03/send-email-with-intent-in-android.html

Categories

Resources