0
private void EmailManager(string ManagerEmail, string EmpName)
{ 
        MailMessage mail = new MailMessage();

        mail.From = new MailAddress("mailaddress");
        mail.To.Add("ManagerEmail");
        mail.Subject = "Birthday Wish";
        var contentID = "Desert";
        var inlineLogo = new Attachment(@"C:\Users\Public\Pictures\Sample Pictures\Down.jpg");
        inlineLogo.ContentId = contentID;
        inlineLogo.ContentDisposition.Inline = true;
        inlineLogo.ContentDisposition.DispositionType = DispositionTypeNames.Inline;

        mail.IsBodyHtml = true;
        mail.Attachments.Add(inlineLogo);
        mail.Body = "<html><body><div style ='background-image:url(\"cid:" + contentID + "\"); width: 100%; height: 500px; padding: 15px; background-repeat: no-repeat;'><span style = 'font-size: 40px; font-family: monotype corsiva; margin: 110px 110px 0 140px; display: inline-block; color: darkgreen;'>Happy Bday '" + EmpName + "'</br> Many-Many Happy Returns of the Day...</br> Stay Blessed </span></div></body></html>";



        SmtpClient smtp = new SmtpClient("address");
        smtp.Send(mail);
}              

here i m sending an image using a location of my drive but i need that the diff images has been sent to different user...how can i do that

LittlePanda
  • 2,496
  • 1
  • 21
  • 33
Anmol
  • 1
  • 1

1 Answers1

0

Check your Image URL may be not correct. You have to get the server path. Server.MapPath()

you can give the name of images like pic1,pic2. 1,2 is the user id and you can set the user id to the image like.

int userid=1;
var inlineLogo = new Attachment(@"C:\Users\Public\Pictures\Sample Pictures\Down"+userid+".jpg"

now you can get images according to user id. but you have to save the images with the users name like pic1,pic2. so you can get. if you wan to choose random images choose random function.

Community
  • 1
  • 1
Jhon Peter
  • 13
  • 1
  • 1
  • 9