Sending MailMessage with LinkedResources

Posts   
 
    
gabrielk avatar
gabrielk
User
Posts: 231
Joined: 01-Feb-2005
# Posted on: 28-Apr-2008 23:56:23   

Hi All,

(Not LLBLGen specific)

I've just created a templating system to create e-mails & parse all the images to LinkedResources (inline-images via cid). It all works fine, but all the inline-images also show up as attachments to the message in Outlook and Gmail (maybe others too). They show up as noname attachments in gmail and ATT_00.bin, ATT_15.bin, etc.. in Outook

Could anyone tell me what this could be? I've Googling for while now but can't find a related posts.

Thanks, Gab

twaindev avatar
twaindev
User
Posts: 178
Joined: 08-Oct-2007
# Posted on: 30-Apr-2008 10:39:05   

IIRC you have to set the ContentType property of the LinkedResource to get rid of the attachments.

Here is a code snippet:

string image = "MyLogo";
LinkedResource res = new LinkedResource(String.Format(@"..\..\images\{0}.gif", image));
res.ContentId = image;
res.ContentType = new ContentType("image/gif");
mail.LinkedResources.Add(res);

If you use another image format you will have to change the content type accordingly.

HTH

gabrielk avatar
gabrielk
User
Posts: 231
Joined: 01-Feb-2005
# Posted on: 01-May-2008 12:12:05   

Thanks a lot for the input, I indeed missed the content types!

gabrielk avatar
gabrielk
User
Posts: 231
Joined: 01-Feb-2005
# Posted on: 08-May-2008 12:59:00   

I didn't seem to have done the job... Any other suggestions?

twaindev avatar
twaindev
User
Posts: 178
Joined: 08-Oct-2007
# Posted on: 08-May-2008 14:33:27   

I'm afraid not. After adding the content type I can open the mails with Outlook, Thunderbird and Lotus Notes. The images are shown where they should be and there are no attachments.

Do you use an AlternateView? How do you refer to the images in the html?

gabrielk avatar
gabrielk
User
Posts: 231
Joined: 01-Feb-2005
# Posted on: 04-Jun-2008 15:11:37   

For future reference:

The problem was that I had the image 'spacer.gif' used multiple times & my routine created multiple resources for the file and used them. For some reason this resulted in all the double items showing up as attachements.

Solution: Make sure that every physical file is only included once per email.

Cheers, Gab