我必須開發一個android應用程序。 在這裏我必須從我的Android應用程序發送郵件。從我的android應用程序發送郵件
我必須從我的android應用程序發送郵件列表視圖vlaues。
這是我的Android代碼:顯示在這些activity.how
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[]{"[email protected]"});
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();
}
}
});
}
ListView中我可以發送列表視圖值email.please給我的解決方案。
編輯:
您好我有發送郵件自動。所以我用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("[email protected]","fg565jhjjh");
}
});
try {
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress("[email protected]"));
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse("[email protected]"));
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);
}
}
});
現在我要automaically列表視圖發送電子郵件。如何我可以設置內容here.please給我的想法。
您想向用戶展示撰寫窗口,還是想自動從您擁有的帳戶發送電子郵件? – SLaks
@ SLaks會自動從我的帳戶發送電子郵件。 – android
您可以爲每個人提供您的電子郵件密碼或設置網絡服務。 – SLaks