網絡連接發送電子郵件,我想創建一個應用程序,它發送郵件帶有附件(選擇
SD卡/庫文件)。我試圖找到相關的代碼,但我沒有找到它。
請給我一些代碼。
下面是用於發送郵件的示例代碼。
在此先感謝。從我的Android應用
Sendbtn.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
// TODO Auto-generated method stub
String TO,CC,Subject,Body,URL;
try
{
URL = Environment.getExternalStorageDirectory()
.getAbsolutePath() + "/temp";
File file = new File(URL);
if (!file.exists())
file.mkdirs();
URL = URL + "/report.html";
createFile();
//
Log.i(getClass().getSimpleName(), "send task - start");
//
final Intent emailIntent = new Intent(
android.content.Intent.ACTION_SEND);
//
TO=(TOEText.getText().toString());
CC=(CCEText.getText().toString());
Subject=(SubjectEText.getText().toString());
URL=(BrowseEText.getText().toString());
Body=(BodyEText.getText().toString());
//
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
new String[] { TO });
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, Subject);
emailIntent.putExtra(Intent.EXTRA_STREAM,
Uri.parse("file://" + URL));
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Body);
//this.startActivity(Intent
//.createChooser(emailIntent, "Send mail..."));
}
catch (Throwable t)
{
Message(t);
}
}
});
}
喜請做一些R&D.no一個將爲您提供直接的代碼。嘗試一下並在這裏發佈你的問題。 – OnkarDhane 2012-02-16 09:09:10
這是我的示例代碼。 – 2012-02-16 09:12:50
@sandiparmal你的代碼在哪裏? – 2012-02-16 09:14:16