How to embed multiple images in email body using .NET

后端 未结 7 2204
孤城傲影
孤城傲影 2020-11-29 06:26

I\'m writing a program that sends emails to users with multiple images (charts) embedded in the Email message body (HTML).

When I tried the sample located here..whic

相关标签:
7条回答
  • Try the following:

    private static ICollection<LinkedResource> GetLinkedResources()
    {
        var linkedResources = new List<LinkedResource>();
    
        linkedResources.Add(new LinkedResource(@"imagepath")
        {
            ContentId = "HeaderId",
            TransferEncoding = TransferEncoding.Base64
        });
    
        linkedResources.Add(new LinkedResource(@"imagepath")
        {
            ContentId = "MapId",
            TransferEncoding = TransferEncoding.Base64
        });
    
        return linkedResources;
    }
    

    Then you can call the method as follows:

     mailMessage.AlternateViews.Add(GetEmbeddedImage(body));
    
    0 讨论(0)
提交回复
热议问题