2010-09-09 46 views
1

的圖像存儲在Android的SD卡發送電子郵件與安卓(解決方案)附圖片

我得到了解決,我們需要指定

<uses-permission android:name="android.permission.SEND_SMS"/> 
清單中

和工作代碼爲:

String _path = Environment.getExternalStorageDirectory() + "/mapp/test.jpeg"; 
File file = new File(_path); 
Uri outputFileUri = Uri.fromFile(file); 

if(file.exists()) 
{ 

//final ConnectivityManager connMgr = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE); 
//final int result = connMgr.startUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE,Phone.FEATURE_ENABLE_MMS); 

    Toast.makeText(context,"exists",Toast.LENGTH_LONG).show(); 
    Intent sendIntent = new Intent(Intent.ACTION_SEND); 
    sendIntent.setType("image/jpeg"); 
    sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] {"[email protected]"}); 
    sendIntent.putExtra(Intent.EXTRA_SUBJECT,"World Toyata(via Android App"); 
    sendIntent.putExtra(Intent.EXTRA_STREAM,outputFileUri); 
    sendIntent.putExtra(Intent.EXTRA_TEXT,"Problem Area Image"); 
    startActivity(Intent.createChooser(sendIntent, "")); 
} 
else 
{ 
    Toast.makeText(context,"SD CARD Required ",Toast.LENGTH_LONG).show(); 
} 

      }     
+0

喜的朋友我在等待UR答覆plz幫助找到一種方法將圖片附加到Android電子郵件 – 2010-09-13 04:40:01

+0

我得到了我們需要指定 – 2010-09-14 08:55:47

+0

你不應該需要對電子郵件 – 2011-03-03 12:39:24

回答

0

Ramesh - 我發現在你的例子中的價值,但也發現它是沒有必要的我有權限android.permission.SEND_SMS。我想知道是否需要有 startActivity(Intent.createChooser(sendIntent,「Email:」));

您指定「電子郵件地址:」的位置。

+0

是的,你可以使用startActivity添加字符串數據(Intent.createChooser(sendIntent,「Email:」));使用上面的行,在我的情況我包括我的客戶名稱其他細節,即爲什麼我離開黑色空間,但無論如何,它將作爲電子郵件發送,因爲我們指定Intent.EXTRA_EMAIL在sendIntent.putExtra(Intent.EXTRA_EMAIL,新字符串[ ] {「[email protected]」}); 所以它只會是一封電子郵件。正如你所說的那樣,SEND_SMS不是必需的,對我的錯誤感到抱歉。 – 2011-03-09 05:34:13

相關問題