Difference between revisions of ".NET"
From Richard's Wiki
(New page: * [http://www.codeproject.com/KB/dotnet/mysteriesofconfiguration.aspx Unraveling the Mysteries of .NET 2.0 Configuration (CodeProject)]) |
|||
| (4 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
| + | * To add an image from a resource to an HTML email using the System.Net.Mail namespace: | ||
| + | <pre> | ||
| + | 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); | ||
| + | </pre> | ||
| + | |||
| + | * [http://www.codeproject.com/Articles/157283/Code-Contracts-in-NET-4-0-its-Internals.aspx?display=Print Code Contracts in .NET 4.0 & its Internals (CodeProject)] | ||
| + | * [http://msdn.microsoft.com/en-us/devlabs/dd491992 Code Contracts (MSDN DevLabs page)] | ||
* [http://www.codeproject.com/KB/dotnet/mysteriesofconfiguration.aspx Unraveling the Mysteries of .NET 2.0 Configuration (CodeProject)] | * [http://www.codeproject.com/KB/dotnet/mysteriesofconfiguration.aspx Unraveling the Mysteries of .NET 2.0 Configuration (CodeProject)] | ||
| + | |||
| + | ===== Improving Performance of .Net Forms Applications ===== | ||
| + | * [http://msdn.microsoft.com/en-us/magazine/cc163630.aspx Practical Tips For Boosting The Performance Of Windows Forms Apps] | ||
| + | * [http://msdn.microsoft.com/en-us/magazine/cc337892.aspx Improving Application Startup Performance] | ||
| + | * [http://msdn.microsoft.com/en-us/library/ms998498.aspx Chapter 8 - Smart Client Application Performance (from P&P Smart Client Architecture and Design Guide)] | ||
Latest revision as of 20:48, 10 October 2011
- 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)