Sending mail using gmail

In order to send mail using a gmail address this can be used:

In Web.config

			<smtp from="" deliveryMethod="Network">
					enableSsl="true" />

And then in the code (in this case C# is used)

SmtpClient smtpClient = new SmtpClient();
smtpClient.UseDefaultCredentials = true; //reads the settings from web.config
smtpClient.Credentials = new System.Net.NetworkCredential("", "mypassword");
//and then send the message

Or if you don’t wish to save any settings in web.config

string host = "";
int port = 587;
SmtpClient smtpClient = new SmtpClient(host, port);
smtpClient.UseDefaultCredentials = false;
smtpClient.EnableSsl = true;
smtpClient.Credentials = new System.Net.NetworkCredential("", "mypassword");
//and then send the message contained in mailMessage

SmtClient at msdn
It might also be interesting to read up on mailmessage

C# parsing through Outlook Calendar items

This code sample will simply parse through all Calendar Items and let us do something with them.
Note: Be aware of what is done here, if there are Items in the Calender with infinite reccurrences (no end date) then this will take forever to parse, so make sure something in the loop causes a break at some point.

	//using the Microsoft Outlook 12 Object library (Microsoft.Office.Interop.Outlook)
	using Microsoft.Office.Interop.Outlook
	Microsoft.Office.Interop.Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application();
	Microsoft.Office.Interop.Outlook.NameSpace mapiNamespace= oApp.GetNamespace("MAPI"); ;
	Microsoft.Office.Interop.Outlook.MAPIFolder CalendarFolder= mapiNamespace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderCalendar);
	Microsoft.Office.Interop.Outlook.Items outlookCalendarItems = CalendarFolder.Items;
	//include recurring events (just a "normal" events i.e once per time it occurs)
	//Have to Sort by Start before setting IncludeRecurrences.
	outlookCalendarItems.IncludeRecurrences = true;
	foreach (Outlook.AppointmentItem item in outlookCalendarItems)
		//Do something with the item

C# MVC# create a URI from a Url.Action

Sometimes the need arises to create a URI object instead of just a link. This can be done by using Url.Action.

new Uri(Url.Action("action", "controller", null, Request.Url.Scheme))
public Uri(
	string uriString
public string Action(
	string actionName,
	string controllerName,
	Object routeValues,
	string protocol