Forum Xamarin Xamarin.Android

Xamarin.Android: How to Attach an Image Using SMTP

JosephK.1507JosephK.1507 USMember
edited June 2016 in Xamarin.Android

Folks -
I've been trying to to attach an image using STMP like so:

MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("");
mail.From = new MailAddress("[email protected]");
mail.To.Add("[email protected]");
mail.Subject = "Message Subject";
mail.Body = "Test sending an image ";
mail.Attachments.Add(image); <<-----------------

this is how I'm creating the image object:

var image = Resource.Drawable.test;
Attachment imagePath = new Attachment(image);
imagePath.ContentType.MediaType = "image/png";
imagePath.ContentType.Name = Path.GetFileName(imagePath);

But clearly I'm doing it incorrectly.
Any pointers will be appreciated.

Thanks in advance


Sign In or Register to comment.