MailMessage mail = new MailMessage();
mail.From = new MailAddress("your@yourdomain.com");
mail.To.Add("user@yourdomain.com"); mail.Subject = "Test mail";
//first we create the Plain Text part
AlternateView plainView = AlternateView.CreateAlternateViewFromString("This is my text , viewable by clients that don't support html", null, "text/plain");
//then we create the Html part
//to embed images, we need to use the prefix 'cid' in the img src value
//the cid value will map to the Content-Id of a Linked resource.
//thus "" will map to a LinkedResource with a ContentId of 'logo'
AlternateView htmlView = AlternateView.CreateAlternateViewFromString("Here is an embedded image."", null, "text/html");
//create the LinkedResource (embedded image)
LinkedResource logo = new LinkedResource( "c:\\temp\\mycompanylogo.gif" );
logo.ContentId = "logo";
//add the LinkedResource to the appropriate view
htmlView.LinkedResources.Add(logo);
//add the views
//mail.AlternateViews.Add(plainView);
mail.AlternateViews.Add(htmlView);
SmtpClient smtp = new SmtpClient("127.0.0.1");
smtp.Send(mail);