我正在寫一個windows服務,它將觸發電子郵件。該功能也可以使用相同的代碼從Windows應用程序觸發。電子郵件與資源文件中提取的簽名標誌
我們觸發的電子郵件應該有一個帶有徽標的簽名,該徽標位於資源文件中。電子郵件被觸發得很好,但圖像沒有顯示,但圖像的佔位符是。這是我使用的代碼:
![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 {}]
有人能幫助我嗎?我錯過了什麼嗎?
我懷疑附件和嵌入式資源之間有細微的差別,這可能被認爲是這樣的重複:http://stackoverflow.com/questions/18358534/send-inline-image-in-email – David
我試過了也是如此,但我認爲我的問題與你提到的帖子有點不同,給出了相同的結果。 (請參閱附件)。該圖像沒有收到罰款。 – Jinith
如果在保存圖像後將mstream.Position設置爲0會怎樣? – jstedfast