1つのAndroidアプリケーションを開発する必要があります。ここでは、Androidアプリケーションからメールを送信する必要があります。
Androidアプリケーションからメールリストビューvlauesを送信する必要があります。
これは私のAndroidコードです:
public class InvoiceOrder extends Activity {
String mGrandTotal,mTitle,total,mCost;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.invoice);
ListView mLstView1 = (ListView) findViewById(R.id.listView1);
CustomerAdapter mViewCartAdpt = new CustomerAdapter(
InvoiceOrder.this);
mLstView1.setAdapter(mViewCartAdpt);
Button login = (Button) findViewById(R.id.mBtnSubmit);
login.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL , new String[]{"demo@mercuryminds.com"});
i.putExtra(Intent.EXTRA_SUBJECT, "Testing");
i.putExtra(Intent.EXTRA_TEXT , "mLstView1");
try {
startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(InvoiceOrder.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}
}
});
}
リストビューはこれらのアクティビティに表示されます。リストビューの値を電子メールに送信するにはどうすればよいですか。解決策を教えてください。
編集:
こんにちは私は自動的にメールを送信しました。だから私はjavamailapiを使用しました。
今、私は私のコードを次のように変更しました:
public class InvoiceOrder extends Activity {
String mGrandTotal,mTitle,total,mCost;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.invoice);
ListView mLstView1 = (ListView) findViewById(R.id.listView1);
CustomerAdapter mViewCartAdpt = new CustomerAdapter(
InvoiceOrder.this);
mLstView1.setAdapter(mViewCartAdpt);
Button login = (Button) findViewById(R.id.mBtnSubmit);
login.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
Properties props = new Properties();
props.put("mail.smtp.host", "smtp.gmail.com");
props.put("mail.smtp.socketFactory.port", "465");
props.put("mail.smtp.socketFactory.class",
"javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "465");
Session session = Session.getDefaultInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("mroslinmhary@gmail.com","fg565jhjjh");
}
});
try {
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress("krishnaveni.veeman@mercuryminds.com"));
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse("demo@mercuryminds.com"));
message.setSubject("Testing Subject");
message.setContent("This is your product name : "+
"Hi Krishna" +"<br></br>This is your price : "+ "Hi veni", "text/html; charset=utf-8");
Transport.send(message);
System.out.println("Done");
} catch (MessagingException e) {
throw new RuntimeException(e);
}
}
});
今、私はリストビューを自動的に電子メールに送信する必要があります。ここでコンテンツを設定するにはどうすればよいですか。アイデアを教えてください。