-1

I am making a windows form to capture image from laptop and send it to phone through email or whatsapp or any other social networking site. Though I got the capturing image code, I couldn't find the code for sending the image. Please help.

1 Answers1

0

You can send email with image with this code:

using (var client = new SmtpClient())
{
    MailMessage newMail = new MailMessage();
    newMail.To.Add(new MailAddress("you@your.address"));
    newMail.Subject = "Test Subject";
    newMail.IsBodyHtml = true;

    var inlineLogo = new LinkedResource(Server.MapPath("~/Path/To/YourImage.png"));
    inlineLogo.ContentId = Guid.NewGuid().ToString();

    string body = string.Format(@"                
            <img src=""cid:{0}"" />
        ", inlineLogo.ContentId);

    var view = AlternateView.CreateAlternateViewFromString(body, null, "text/html");
    view.LinkedResources.Add(inlineLogo);
    newMail.AlternateViews.Add(view);

    client.Send(newMail);
}

https://stackoverflow.com/a/11000938/5364144

Samuel Tulach
  • 1,319
  • 13
  • 38