How to send emails from my Android application?

The best (and easiest) way is to use an Intent: Intent i = new Intent(Intent.ACTION_SEND); i.setType(“message/rfc822”); i.putExtra(Intent.EXTRA_EMAIL , new String[]{“recipient@example.com”}); i.putExtra(Intent.EXTRA_SUBJECT, “subject of email”); i.putExtra(Intent.EXTRA_TEXT , “body of email”); try { startActivity(Intent.createChooser(i, “Send mail…”)); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(MyActivity.this, “There are no email clients installed.”, Toast.LENGTH_SHORT).show(); } Otherwise you’ll have to write your own … Read more

C# code to validate email address

What about this? bool IsValidEmail(string email) { var trimmedEmail = email.Trim(); if (trimmedEmail.EndsWith(“.”)) { return false; // suggested by @TK-421 } try { var addr = new System.Net.Mail.MailAddress(email); return addr.Address == trimmedEmail; } catch { return false; } } Per Stuart’s comment, this compares the final address with the original string instead of always returning … Read more

Send Email Intent

UPDATE Official approach: public void composeEmail(String[] addresses, String subject) { Intent intent = new Intent(Intent.ACTION_SENDTO); intent.setData(Uri.parse(“mailto:”)); // only email apps should handle this intent.putExtra(Intent.EXTRA_EMAIL, addresses); intent.putExtra(Intent.EXTRA_SUBJECT, subject); if (intent.resolveActivity(getPackageManager()) != null) { startActivity(intent); } } Ref link OLD ANSWER The accepted answer doesn’t work on the 4.1.2. This should work on all platforms: Intent emailIntent … Read more

Sending Email in Android using JavaMail API without using the default/built-in app

Send e-mail in Android using the JavaMail API using Gmail authentication. Steps to create a sample Project: MailSenderActivity.java: public class MailSenderActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final Button send = (Button) this.findViewById(R.id.send); send.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { try { GMailSender sender = new GMailSender(“username@gmail.com”, “password”); sender.sendMail(“This … Read more

What characters are allowed in an email address?

See RFC 5322: Internet Message Format and, to a lesser extent, RFC 5321: Simple Mail Transfer Protocol. RFC 822 also covers email addresses, but it deals mostly with its structure: addr-spec = local-part “@” domain ; global address local-part = word *(“.” word) ; uninterpreted ; case-preserved domain = sub-domain *(“.” sub-domain) sub-domain = domain-ref … Read more

Sending email in .NET through Gmail

Be sure to use System.Net.Mail, not the deprecated System.Web.Mail. Doing SSL with System.Web.Mail is a gross mess of hacky extensions. using System.Net; using System.Net.Mail; var fromAddress = new MailAddress(“from@gmail.com”, “From Name”); var toAddress = new MailAddress(“to@example.com”, “To Name”); const string fromPassword = “fromPassword”; const string subject = “Subject”; const string body = “Body”; var smtp … Read more

Can I set subject/content of email using mailto:?

Yes, look all tips and tricks with mailto: http://www.angelfire.com/dc/html-webmaster/mailto.htm mailto subject example: <a href=”https://stackoverflow.com/questions/4782068/mailto:no-one@snai1mai1.com?subject=free chocolate”>example</a> mailto with content: <a href=”mailto:no-one@snai1mai1.com?subject=look at this website&body=Hi,I found this website and thought you might like it http://www.geocities.com/wowhtml/”>tell a friend</a> As alluded to in the comments, both subject and body must be escaped properly. Use encodeURIComponent(subject) on each, rather than … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)