Send e-mail with attachment using intent from a xamarin forms don't compile-Java.Interop missing ref

lpinholpinho USMember ✭✭

Hi,

I'm building a xamarin forms application and I want to send an e-mail using an intent.

This is the code behind of a xaml page:

         var intent = new Intent(Intent.ActionSend);
        intent.SetType("message/rfc822");
        intent.PutExtra(Intent.ExtraSubject, "WeTV Channel Organizer db file");
        intent.PutExtra(Intent.ExtraEmail, new[] { emailAddress });
        Android.Net.Uri uri = Android.Net.Uri.Parse("file://" + fileName);
        if (uri != null)
        { 
            intent.PutExtra(Intent.ExtraStream, uri);
            Android.App.Application.Context.StartActivity(Intent.CreateChooser(intent, "Send email"));
        }

This is the error that is triggered on compile:

The type 'IJavaPeerable' is defined in an assembly that is not referenced. You must add a reference to assembly 'Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'

Should I force adding a reference to that assembly?
Should I trigger this code from the MainActivity (I'm using messaging to trigger a KeyDown from the MainActivity to the forms, but I'm not able to pass parameters)?

Thanks for the help

Sign In or Register to comment.