My sender Mail id isabcdefg@pqr.com and receiver email_id will
any... so how can do that in android, i seen and search too much on net but not get proper way, people say use Intent and all... so please give me proper path to reach destination on mail send by android app.
i do like this but give me error com.sun.mail.util.MailConnectException: Couldn't connect to host, port: smtp. and more.
This is my code which i tried.
import android.app.ProgressDialog;import android.os.AsyncTask;import android.os.Bundle;import android.widget.Toast;import java.io.File;import java.util.Properties;import javax.mail.Message;import javax.mail.MessagingException;import javax.mail.Multipart;import javax.mail.PasswordAuthentication;import javax.mail.Session;import javax.mail.Transport;import javax.mail.internet.InternetAddress;import javax.mail.internet.MimeBodyPart;import javax.mail.internet.MimeMessage;import javax.mail.internet.MimeMultipart;public class MainActivity extends BaseActivity { private static final String username = "info@fdggdfg.com"; private static final String password = "asdf@"; private static final String emailid = "info@fdggdfg.com"; private static final String message = "Hello this is testing mail"; public String jobNo; public String teamNo; public File mediaFile; private Multipart multipart = new MimeMultipart(); private MimeBodyPart messageBodyPart = new MimeBodyPart(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); AsyncTaskRunner runner = new AsyncTaskRunner(); runner.execute("hardik"); } private class AsyncTaskRunner extends AsyncTask<String, String, String> { ProgressDialog progressDialog; private String resp; @Override protected String doInBackground(String... params) { Properties props = new Properties(); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.host", "smtp.fdggdfg.com"); props.put("mail.smtp.port", "465"); Session session = Session.getInstance(props, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(username, password); } }); try { Message message = new MimeMessage(session); message.setFrom(new InternetAddress("info@fdggdfg.com")); message.setRecipients(Message.RecipientType.TO, InternetAddress.parse("gfdg@gmail.com")); message.setSubject("Testing Subject"); message.setText("Dear Mail Hardik,"+"\n\n No spam to my email, please!"); Multipart multipart = new MimeMultipart(); message.setContent(multipart); Transport.send(message); System.out.println("Done"); } catch (MessagingException e) { throw new RuntimeException(e); } String result ; return result= "done"; } @Override protected void onPostExecute(String result) { // execution of result of Long time consuming operation progressDialog.dismiss(); // finalResult.setText(result); Toast.makeText(MainActivity.this,result,Toast.LENGTH_LONG).show(); } @Override protected void onPreExecute() { progressDialog = ProgressDialog.show(MainActivity.this, "mail", "bhai chalu"); } @Override protected void onProgressUpdate(String... text) { // finalResult.setText(text[0]); } }}