2014-03-19 41 views

回答

0

使用意圖發送電子郵件類似下面的方式..如果ü要添加一些字符串作爲附件u必須保存的內容添加到某個目錄以.html分機後來U可以將其添加爲附件到電子郵件的意圖。 [本爲主意代碼,它可能需要一些修改按照烏爾應用要求..

String emailText = "email message"; 
    final Intent emailIntent = new Intent(Intent.ACTION_SEND); 
    emailIntent.setType("plain/text"); 
    emailIntent.setType("message/rfc822"); 
    emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "[email protected]"}); 
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Hi");  
    emailIntent.putExtra(Intent.EXTRA_TEXT, emailText); 

    String attachContent = "<html> content </html>"; 
    /* this method u have to write, to save the string into html file 
    into cache or any other dir */ 
     saveFile(getCacheDir()+"/attach.html", attachContent); 
     File file = new File(root, getCacheWebDir()+"/attach.html"); 
     Uri uri = Uri.fromFile(file); 
     emailIntent.putExtra(Intent.EXTRA_STREAM, uri); 
     this.startActivity(Intent.createChooser(emailIntent, "Send mail...")); 
相關問題