Quantcast
Channel: Rebex Q&A Forum - Recent questions and answers
Viewing all articles
Browse latest Browse all 3862

Answered: How to convert linked resources to attachments

$
0
0

Actually, you should copy MediaType and other properties as well. So your code should look like this:

foreach (var res in mail.Resources)
{
    if (res.ContentId == null)
        continue;

    var att = new Attachment(res.GetContentStream(), res.FileName, res.MediaType);
    att.ContentId = res.ContentId;
    if (res.ContentDescription != null)
        att.ContentDescription = res.ContentDescription;
    if (res.ContentLocation != null)
        att.ContentLocation = res.ContentLocation;
    mail.Attachments.Add(att);
}

Viewing all articles
Browse latest Browse all 3862

Trending Articles