gpt4 book ai didi

java - 发送带有附件的电子邮件,发送一个空白文件

转载 作者:行者123 更新时间:2023-12-01 15:55:43 28 4
gpt4 key购买 nike

我正在使用此代码:

File myDir = new File(getApplicationContext().getFilesDir().getAbsolutePath());
try {
Log.i("CSV Testing ", "CSV file creating");
FileWriter fw = new FileWriter(myDir + "/myfile.csv");
//
// write data to file
//
Log.i("CSV Testing ", "CSV file created and your data has been saved");
// Process for sending email with CSV file
File CSVFile = new File(myDir,"myfile.csv");
// And sending it with email attachment
} catch (IOException e) {
Log.i("ExportCSV Exception", e.toString());
}

但它会将 myfile.csv 作为空白文件发送。我从文件资源管理器中检查了它,其中 myfile.csv 不为空并且包含正确的数据。我该如何解决这个问题?

我的 Logcat 消息是

I/CSV Testing (16920): CSV file creating
I/CSV Testing (16920): CSV file created and your data has been saved
I/CSV FILE(16920): CSV file exists
I/SEND EMAIL TESTING(16920): Email sending
D/dalvikvm(16920): GC freed 2902 objects / 186576 bytes in 156ms
I/ActivityManager( 60): Starting activity: Intent { act=android.intent.action.CHOOSER cmp=android/com.android.internal.app.ChooserActivity (has extras) }
W/ActivityManager( 60): startActivity called from non-Activity context; forcing Intent.FLAG_ACTIVITY_NEW_TASK for: Intent { act=android.intent.action.CHOOSER flg=0x800000 cmp=android/com.android.internal.app.ChooserActivity (has extras) }
I/ActivityManager( 60): Displayed activity com.android.email/.activity.MessageCompose: 1156 ms (total 2117 ms)
W/InputManagerService( 60): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@43cf3050 (uid=10023 pid=207)
W/IInputConnectionWrapper( 207): showStatusIcon on inactive InputConnection

最佳答案

如果确实是这种情况,则您的文件路径一定在某个地方丢失,这意味着您的文件路径一定不正确。

因此,语句 File CSVFile = new File(myDir,"myfile.csv"); 必须在该位置创建新的空文件。

关于java - 发送带有附件的电子邮件,发送一个空白文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5101575/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com