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

Hello,
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);
        email.PutExtra(Android.Content.Intent.ExtraText,text);
        if (fileNameAttachment != null)
        {
            var uri = new System.UriBuilder("file://" + fileNameAttachment);
            email.PutExtra(Android.Content.Intent.ExtraStream, uri); // <=== this is not allowed
        }

        email.SetType("message/rfc822");

        _email = email;

thanks

Best Answer

Answers

  • YamilBrachoYamilBracho VEMember

    Try
    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.