Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

email send with attachments issue in xamarin android

$
0
0

I am sending email in xamarin android using this code. email is sending without attachment. not getting any error but attachments are not sending with the email.

` public void SendEmail(string toEmail, string subject, string text, string filePath)
{
var intent = new Intent(Android.Content.Intent.ActionSend);

        if (!string.IsNullOrEmpty(toEmail))
            intent.PutExtra(Intent.ExtraEmail,
                toEmail.Split(new[] { ',', ';', ' ' }, StringSplitOptions.RemoveEmptyEntries));

        if (!string.IsNullOrEmpty(subject))
            intent.PutExtra(Intent.ExtraSubject, subject);

        if (!string.IsNullOrEmpty(text))
            intent.PutExtra(Intent.ExtraText, text);

        if (!string.IsNullOrEmpty(filePath))
        {
            var file = new File(filePath);
            file.SetReadable(true, false);

            var uri = Uri.FromFile(file);
            intent.PutExtra(Intent.ActionView, uri);
        }

        intent.SetType("text/plain");
         var intentChooser = Intent.CreateChooser(intent, (string)null);
         intentChooser.AddFlags(ActivityFlags.NewTask);
         CrossCurrentActivity.Current.Activity.StartActivity(intentChooser);  
    } `

Viewing all articles
Browse latest Browse all 89864

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>