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();
}
};