How do I attach a file to an email with email.PutExtra(Android.Content.Intent.ExtraStream

below is my code:
var email = new Intent(Android.Content.Intent.ActionSend);
email.PutExtra(Android.Content.Intent.ExtraEmail, SendTo);

        email.PutExtra(Android.Content.Intent.ExtraCc, SendCC);
        email.PutExtra(Android.Content.Intent.ExtraSubject, subject);
        if (fileNameAttachment != null)
            var uri = new System.UriBuilder("file://" + fileNameAttachment);
            email.PutExtra(Android.Content.Intent.ExtraStream, uri); // <=== this is not allowed


        _email = email;


Best Answer


  • YamilBrachoYamilBracho VEMember

    email.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///" + fileNameAttachment));

  • SergioMatteoniSergioMatteoni ITMember

    @YamilBracho Thanks fr answer, I tried what you told me but the class System.Uri not contains .Parse method

  • SergioMatteoniSergioMatteoni ITMember

    @Cheesebaron Thanks, perfect, now work fine.

  • syamilsyamil USMember

    Android.Net.Uri works fine to me too. nice.

  • ChitoSalanoChitoSalano PHUniversity ✭✭

    Hello, would anyone know if we could possibly attach a file from memorystream to the Intent ActionSend?

    We don't want to create a file in the external storage. Thanks in advance.

Sign In or Register to comment.