I am writing a Windows service which will trigger emails. The functionality can also be triggered from a Windows application using the same piece of code.
The emails which we trigger should be having a signature with a logo, which is in a resource file. The emails are getting triggered fine but the image is not showing up, but the placeholder for image is. This is the code I am using:
try
{
Bitmap imgAttachment = Project.Shared.Properties.Resources.Image1;
using (MemoryStream mstream = new MemoryStream())
{
ContentType type = new ContentType()
{
MediaType = MediaTypeNames.Image.Jpeg,
Name = "attachment"
};
imgAttachment.Save(mstream, ImageFormat.Jpeg);
Attachment sigAttachment = new Attachment(mstream, type);
string ContentId = "imagelogo";
sigAttachment.ContentId = ContentId;
sigAttachment.ContentDisposition.Inline = true;
sigAttachment.ContentDisposition.DispositionType = DispositionTypeNames.Inline;
message.Attachments.Add(sigAttachment);
message.Body = Body + "<htm><body> <br/><br/><table border='0' cellpadding='0'
cellspacing='0' width='1000'> <tr><td> </td></tr> <tr> <td
rowspan='8' valign='top' align='left'><img alt = 'Logo' src=\"cid:" +
ContentId + "\"></td> <td width='1000' height='46' valign='top'> " +
SignatureLine1 + " </td> </tr> <tr> " + SignatureLine2 + " </tr> <tr> " +
SignatureLine3 + " </tr> <tr> " + SignatureLine4 + " </tr> </table>
</body></html>";
client.Send(message);
}
}
catch {}
Can some one help me with this? Am I missing something?