1

We are making an app that do some process and finally send report via email to user via both port 587 & 465 . For port 567, we use standard System.Net.Mail and everything works fine. For the other port 465, we use AegisImplicitMail and we can't send image inline.

Here is the code for sending inline image with port 587

if (SettingDao.GetSMTPPort() == 587)
        {
            InlineChartExplicit = new Attachment(ChartDayImg);
            string contentID = "inlineChartExplicit";
            InlineChartExplicit.ContentId = contentID;
            InlineChartExplicit.ContentDisposition.Inline = true;
            InlineChartExplicit.ContentDisposition.DispositionType = DispositionTypeNames.Inline;

            Html += @"<img src='cid:" + InlineChartExplicit.ContentId + @"' + style='width:50%;height:50%'/>";

        }

and in emailService

if (InlineAttmExplicitSSL != null)
{
    mail.Attachments.Add(InlineAttmExplicitSSL);
}

then we use the same code for port 465 using AegisImplicitMail, but the inline image does not work. Instead, we have an attachment at the end of the email

else if (SettingDao.GetSMTPPort() == 465)
        {
            InlineChartImplicit = new MimeAttachment(ChartDayImg);
            string contentID = "inlineChartImplicit";
            InlineChartImplicit.ContentId = contentID;
            InlineChartImplicit.ContentDisposition.Inline = true;
            InlineChartImplicit.ContentDisposition.DispositionType = DispositionTypeNames.Inline;

            Html += @"<img src='cid:" + InlineChartImplicit.ContentId + @"' + style='width:50%;height:50%'/>";

        }

in emailservice:

if (InlineAttmImplicitSSL != null)
        {
            mailMessage.Attachments.Add(InlineAttmImplicitSSL);
        }

Is there something we missed for AegisImplicitMail? Thanks.

hieuvt
  • 11
  • 2
  • After debuging, we found that AegisImplicitMail.MimeAttachment contains public AttachmentLocation Location { get; set; }. AttachmentLocation is an enum type: public enum AttachmentLocation { Attachmed = 0, Inline = 1 } - by default AttachmentLocation.Attachmed is used, maybe that's why the image is attached at the bottom of our email instead of inline. We try to set AttachmentLocation.Inline but it does not work. We got message "If you can see this, then your email client does not support MHTML messages." in the email. – hieuvt May 08 '18 at 18:28
  • we found that there is an at the desired position without src, so nothing is displayed. – hieuvt May 09 '18 at 01:28

0 Answers0