.NET
From Richard's Wiki
- To add an image from a resource to an HTML email using the System.Net.Mail namespace:
using System.Drawing.Imaging; using System.IO; using System.Net.Mail; using System.Net.Mime; ... string logoCid = "logo"; MemoryStream logoStream = new MemoryStream(); Resources.Logo.Save(logoStream, ImageFormat.Jpeg); logoStream.Seek(0, SeekOrigin.Begin); LinkedResource logo = new LinkedResource(logoStream, MediaTypeNames.Image.Jpeg) { ContentId = logoCid }; string fmt = @"<table style='width:100%;'><tr><td><img align='left' src='cid:{0}'></td></tr></table>"; string html = string.Format(fmt, logoCid); AlternateView htmlView = AlternateView.CreateAlternateViewFromString(html, null, MediaTypeNames.Text.Html); htmlView.LinkedResources.Add(logo);
- Code Contracts in .NET 4.0 & its Internals (CodeProject)
- Code Contracts (MSDN DevLabs page)
- Unraveling the Mysteries of .NET 2.0 Configuration (CodeProject)