Send inline image in email

前端 未结 12 2028
夕颜
夕颜 2020-11-22 11:09

Having an issue sending an image via email as an embedded image in the body. The image file shows as an attachment which is ok but the inline image portion just shows as a r

12条回答
  •  醉酒成梦
    2020-11-22 11:50

    The other solution is attaching the image as attachment and then referencing it html code using cid. HTML Code:

    
    
    
    
        
    
    
    

    C# Code:

    EmailMessage email = new EmailMessage(service);
    email.Subject = "Email with Image";
    email.Body = new MessageBody(BodyType.HTML, html);
    email.ToRecipients.Add("abc@xyz.com");
    string file = @"C:\Users\acv\Pictures\Logo.jpg";
    email.Attachments.AddFileAttachment("Logo.jpg", file);
    email.Attachments[0].IsInline = true;
    email.Attachments[0].ContentId = "Logo.jpg";
    email.SendAndSaveCopy();
    

提交回复
热议问题