I have an ecard application that allows a user to pick an image and send an email. But I am not able to figure out how to send the email here is my code.
protected void SendEmail()
{
StringBuilder message;
Attachment attachFile;
string sImage = System.Web.HttpContext.Current.Server.MapPath("~/DesktopModules/KDMC_EcardList/images/" + txtCapture.Text);
LinkedResource yourPictureRes = new LinkedResource(txtCapture.Text, MediaTypeNames.Image.Jpeg);
yourPictureRes.ContentId = "YourPictureId";
altView.LinkedResources.Add(yourPictureRes);
//Internal Message
message = new StringBuilder();
message.AppendLine(@"<p><img src=cid: sImage /></p>");
message.AppendLine(@"<pre><table style='width:650px; word-break:break-word; height:auto;'>
</td><tr><td style='width:150px;'>From: </td><td style='width:500px;'>" + txtFName.Text + " " + txtLName.Text + @"
</td><tr><td>To: </td><td>" + txtFriendFName.Text + " " + txtFriendLName.Text + @"
</td><tr><td>Room Number: </td><td>" + txtRoom.Text + @"
</td><tr><td>Message: </td><td>" + txtMessage.Text + @"
</td><tr><td>Date Sent: </td><td>" + DateTime.Now.ToString() + "</td></tr></table></pre>");
//attachFile = new Attachment(FileUploadVideo.PostedFile.InputStream, strFileName);
System.Threading.Thread.Sleep(1000);
// need to create new reference to attachment, cannot use same reference to send email twice
//attachment = new Attachment(theMemoryStream, strSubject);
Mail.SendMail("test@test.net", "test@test.net", "", "test@test.net",
"test@test.net", MailPriority.Normal, "A new Ecard has been submitted", MailFormat.Html, Encoding.UTF8, message.ToString(),
new List<Attachment>() { }, null, null, null, null, Host.EnableSMTPSSL);
}
I tried to follow the example here C# add image to email body as well as other solutions in the community but I am still unable to find a solution.