Skip to content

Blog

Embedding your Company Logo in Emails sent with C

Sending emails with C# is straightforward. You only need a few lines of code and a bit of configuration for the mail server as described in an earlier post. Taking the effort to send an email as a base line, you could jump to the conclusion that it shouldn't be a problem to display your company logo inside your generated emails. But unfortunately it's not that easy. That logo should be displayed in the content of the email and not just be added to the list of attachments. And embedded images are a totally different story.

What seems to be an easy task can take hours. However, if you are willing to take some dirty shortcuts you can implement that requirement in a few lines of code.

Saving Emails to Disk in C

Sending emails in C# is a simple task. All you need is a MailMessage object with your email and a SmtpClient to send it:

var toAddress = "[email protected]";
var fromAddress = "[email protected]";
var message = "your message goes here";

// create the email
var mailMessage = new MailMessage();
mailMessage.To.Add(toAddress);
mailMessage.Subject = "Sending emails is easy";
mailMessage.From = new MailAddress(fromAddress);
mailMessage.Body = message;

// send it (settings in web.config / app.config) 
var smtp = new SmtpClient();
smtp.Send(mailMessage);

Protect your Data with a Disposable Email Address

The constant demand to create an account with every web site or app is annoying. As if this is not bad enough, it also puts your data at risk. You use your email everywhere, even when you only need this free WiFi for an hour or two. The data remains on the site and as we can see on sites like Have I been pwned?, it gets "lost" quiet often – and not only by small companies. Combine those leaked accounts with the fact that most people reuse their passwords and you end up with a serious security problem.

Visual Studio 2017: Get your Browser Back!

A new feature of Visual Studio 2017 is really annoying: Whenever you run a web application, it opens a different browser (Google Chrome or Internet Explorer). Not just a new window, but an entirely different executable without your plugins or your settings for self-signed SSL certificates on localhost. To make things worse, those alternative browsers are (at least on my machine) unbearable slow.

How to Configure IIS Express to Accept SSL Client Certificates

Developing applications with SSL client certificates are a challenge because there are so many little things that can go wrong. You quickly want to open the debugger, but that can be a challenge in itself, especially when the whole chain only works on a remote server. A much simpler way is to use IIS Express with a configuration that accepts SSL client certificates. This setup allows you to debug your application on your local machine without the need to configure the full IIS – at least as long as the errors are in your application.

Working Effectively with Cookies in Google Chrome

I use the built-in developer tools of Google Chrome whenever I develop web applications. They offer me nearly everything I need for debugging and to solve problems with CSS. However, there is one spot where those tools fall short: Cookies.
You can see the cookies and modify them. But in comparison to the other parts it feels clumsy and complicated.

My Highlights of NDC Oslo 2017

The 10th edition of the NDC (Norwegian Developers Conference) in Oslo was the best I ever attended. Kjersti and her team made everyone welcome and created a friendly and familiarly atmosphere. This is no easy task, especially not with 2000 attendees. But even at this size you always felt a personal touch and if you needed something, you would always find one of the organizers.

Between the talks you had enough time to meet with old friends and make new ones. Talking in person to people you know from Twitter is a great way to connect on a different level. And let's not forget the food. The NDC has plenty and if you don't like a dish, you have other offerings that should meet your taste.

Export all Saved Passwords from Google Chrome

Google Chrome lets you save your passwords in its password store. While this is a convenient function, it may not be the most trustworthy one. If you trust Google and only use one computer, this may be fine. However, should you try to move your passwords into a service like 1Password, Last Pass or the KeePass application, you will figure out a small problem: The dialog to access your passwords allows you to view only one password at a time:

Chrome saved passwords