Attach imageView to send mail

0

Hello, who can help me, I need to send an attachment imageView in an email ... I did not find the form.

Thanks for your help.

Sent code.

Code with which I add the image the APP

       {
            var imageIntent = new Intent();
            imageIntent.SetType("image/*");
            imageIntent.SetAction(Intent.ActionGetContent);
            StartActivityForResult(Intent.CreateChooser(imageIntent, "Select photo"), 0);
        };
    }
    public override void OnActivityResult(int requestCode, Result resultCode, Intent data)
    {
        base.OnActivityResult(requestCode, resultCode, data);

        if (resultCode == Result.Ok)
        {
            imageView = textView.FindViewById<ImageView>(Resource.Id.ImgMostrarFotos);
            imageView.SetImageURI(data.Data);
            imageView.Visibility = ViewStates.Visible;
            Enviar.Visibility = ViewStates.Visible;
        }
    }

Code with which you sent email, but without the attached image.

        Enviar.Click += delegate 
        {
            try
            {
                 string smtpAddress = "smtp.gmail.com";
                int portNumber = 587;
                bool enableSSL = true;
                string emailFrom = "[email protected]";
                string password = "xxxxxxxxxxxxxxxxx";
                string emailTo = "[email protected]";
                string subject = "Tramite Autorización "+ mTxtNombre;
                string body = "Hello, Mr."+mTxtCedula;
                MailMessage mail = new MailMessage();
                mail.From = new MailAddress(emailFrom);
                mail.To.Add(emailTo);
                mail.Subject = subject;
                mail.Body = body;
                mail.IsBodyHtml = true;

                using (SmtpClient smtp = new SmtpClient(smtpAddress, portNumber))
                {
                    smtp.Credentials = new NetworkCredential(emailFrom, password);
                    smtp.EnableSsl = enableSSL;
                    smtp.Send(mail);
                }

                Toast.MakeText(Activity, "Mensaje Enviado" , ToastLength.Short).Show();
            }
            catch (Exception ex)

            {
                Toast.MakeText(Activity, "Mensaje Fallido" +ex, ToastLength.Short).Show();
            }
        };
    
asked by Andrés Felipe Contreras Muñoz 08.08.2017 в 18:06
source

1 answer

0
    private void MBtnAdjuntar_Click(object sender, EventArgs e)

    {
        var imageIntent = new Intent();
        imageIntent.SetType("image/*");
        imageIntent.SetAction(Intent.ActionGetContent);
        StartActivityForResult(Intent.CreateChooser(imageIntent, "Select photo"), 0);

    }
      public override void OnActivityResult(int requestCode, Result resultCode, Intent data)
    {
        base.OnActivityResult(requestCode, resultCode, data);

        if (resultCode == Result.Ok)
        {
            imageView = textView.FindViewById<ImageView>(Resource.Id.ImgMostrarFotos);
            imageView.SetImageURI(data.Data);
            imageView.Visibility = ViewStates.Visible;
            uris = GetPathToImage(data.Data);

        }
    }
    
answered by 28.08.2017 в 23:15