Not able to send .csv file with email in android -
i going attach ".csv" in mail , send it. facing problem csv file not available @ receiver side.
i have tried many mime types
application/octet-stream, text/comma-separated-values, text/csv, application/csv, application/excel, application/vnd.ms-excel, application/vnd.msexcel
but file not attached mail.
below code have used send mail
public boolean sendemail() { boolean success = false; intent intentsendmail = new intent(intent.action_send); file mydir = getapplicationcontext().getdir(global.foldername, context.mode_private); file filewithinmydir = new file(mydir, global.filename); if (!filewithinmydir.exists() || !filewithinmydir.canread()) { toast.maketext(this, "attachment error", toast.length_short).show(); success = false; } else { intentsendmail.settype("text/csv"); intentsendmail.putextra(intent.extra_stream, uri.fromfile(filewithinmydir)); intentsendmail.putextra(intent.extra_subject, "subject"); intentsendmail.putextra(intent.extra_text, "sent phone."); startactivity(intent.createchooser(intentsendmail, "e-mail")); success = true; } return success; }
thanks in advance..
try out below:
string file = environment.getexternalstoragedirectory() + file.separator + "foldername"; intent sendintent = new intent(android.content.intent.action_send); sendintent.settype("application/csv"); sendintent.putextra(android.content.intent.extra_email, ""); sendintent.putextra(intent.extra_subject, ""); sendintent.putextra(intent.extra_text, ""); string temp_path = file + "/" + "filename.csv"; file f = new file(temp_path); uri u = uri.fromfile(f); sendintent.putextra(intent.extra_stream, u); startactivity(intent.createchooser(sendintent, "send mail"));
hope you.
Comments
Post a Comment