After much struggle, I have been able to get it working correctly with a help from codeproject. I am attaching the link here to help anybody and also give the guy who helped me credit
Attach an Image stored in a Sql server table and a folder in my application using MailMessage C#
I am using MVC5 aspplication and storing an image in both sql server table and a folder in my application and I want to add the image as an attachment to an email to users using MailMessage class. My image source looks like this:
"<p><img src=\"/postedImage/baby220210629224910.jpg\"><br></p>"
from my Linq query
public ActionResult NewsEvents(PostVM entity )
{
var dbnew = new Post();
dbnew.newsId = entity.newsId;
dbnew.Content = entity.Content;
using (var mail = new MailMessage())
{
mail.Attachments.Add(new Attachment(dbnew.Content)); dbnew.Content --->"<p><img src=\"/postedImage/baby220210629224910.jpg\"><br></p>"
}
I get an error "Illegal characters in path."
How do I get only "baby220210629224910.jpg" from the path above