Email photos and photo albums using explorer RRS feed

  • Question

  • Its been a while since I wanted e-mail photos to my friends.  It used to be easy. There was a photo icon and you would merely typen in the body about the photos and press the camera icon.  Now everybody wants you to use "dropbox" or some other "cloud" feature.  Can you still use explorer to email multiple photos?
    Saturday, July 2, 2016 2:40 AM


  • Of course you can send email from your application with attachment(s).

    Please find the below code snippet to achieve that.

    using System.Net.Mail;
    using (MailMessage mailMessage = new MailMessage())
            mailMessage.From = new MailAddress("user@gmail.com");
            mailMessage.Subject = txtSubject.Text.Trim();
            mailMessage.Body = txtBody.Text.Trim();
            mailMessage.IsBodyHtml = true;
            mailMessage.To.Add(new MailAddress(txtTo.Text.Trim()));
            mailMessage.Attachments.Add(new Attachment(file.InputStream, Path.GetFileName(file.FileName), file.ContentType));
            SmtpClient smtp = new SmtpClient();
            smtp.Host = "smtp.gmail.com";
            smtp.EnableSsl = true;
            System.Net.NetworkCredential NetworkCred = new System.Net.NetworkCredential();
            NetworkCred.UserName = mailMessage.From.Address;
            NetworkCred.Password = "<Password>";
            smtp.UseDefaultCredentials = true;
            smtp.Credentials = NetworkCred;
            smtp.Port = 587;

    if you want multiple attachments then call

    mailMessage.Attachments.Add(new Attachment(file.InputStream, Path.GetFileName(file.FileName), file.ContentType));

    this inside for loop or foreach loop.

    If it answers your query then don't forget to mark it as answer so that others can benefit from it also.


    Monday, July 4, 2016 5:41 AM