Send email in .NET Core using Mailkit and office 365

Using SmtpClient to send email .NET core is obsolete. The current recommendation is to use the MailKit library . Here is how to use it with the office 365 SMTP servers.

var message = new MimeMessage();
message.From.Add(new MailboxAddress("{from name}", "{from email address}"));
message.To.Add(new MailboxAddress("{to name}", "{to email address}"));
message.Subject = "{subject}";

message.Body = new TextPart("plain")
{
    Text = "{body}"
};

using (var client = new SmtpClient())
{
    await client.ConnectAsync("smtp.office365.com", 587, SecureSocketOptions.StartTls);
    await client.AuthenticateAsync("{from email address}", "{from password}");
    await client.SendAsync(message);
    await client.DisconnectAsync(true);
}

Difference between mit, gpl and apache software license

The MIT, BSD, and ISC licenses are “permissive licenses”. They are extremely short and essentially say “do whatever you want with this, just don’t sue me.”

The Apache license says “do whatever you want with this, just don’t sue me” but does so with many more words, which lawyers like because it adds specificity. It also contains a patent license and retaliation clause which is designed to prevent patents (including patent trolls) from encumbering the software project.

The GPL licenses (GPLv3, GPLv2, LGPL, Affero GPL) all contain some kind of share-alike license. They essentially say “if you make a derivative work of this, and distribute it to others under certain circumstances, then you have to provide the source code under this license.” The important thing to know here is that “derivative work” and “certain circumstances” both require some legal analysis to understand the meaning and impact for your project.

You can read more about it here;

Backup calendars and contacts in outlook

Recently I had an issue where I need to clean up my inbox in outlook. I lost all of my calendars, schedules and contacts. sometime you learn it hard way 🙂

My emails were sync with exchange service provider so they stay the safe. All I wanted to do is to backup calendars and contacts. Here is a step by step guide;

Click on File -> Open & Export -> Import/Export.

Select “Export to a file” and Click Next.

Select “Outlook Data File (.pst)” and Click Next.

Select “Calendar” and click Next.

Select location and filename for exported file;

You can do the same with contacts.

Steps to perform when relocating to a different city/state

This is a brief list of steps to be performed when relocating to a different city/state.

  1. Inform your current landlord about the date you are moving out
  2. Disable/remove any rental auto payments
  3. Inform your Power provider to disconnect power
  4. Inform your Cable/Internet provider to disconnect service
  5. Inform your postal service provider about your new mailing address

More to come..

Shortcuts to run window command with elevated permission

A common trick to run command in elevated permission is to right click and select Run As administrator. Other work arounds are;

  1. Press Ctrl+Shift+Esc to open the Task Manager. Click on File menu > Run new task. To open a command prompt window, type cmd. Remember to check the Create this task with administrative privileges check-box. Then hit Enter.
  2. You can also open an elevated command prompt from the Task Manager using CTRL Key.
  3. Simply open the Start Menu or Start Screen and start typing the command line. Next, hold the Shift and Ctrl keys, and then hit Enter to open the command line in an elevated command prompt.