cyprich.com

By

MSSQL: How To Get Database Out of Single User

The SQL Server Single User Mode only permits one connection to a database at a time. Great for testing, but not for deployment. Here is how you can get it out of this state. Read More

By

MSSQL: How to Get Database Out of “Restoring” State

When you backup a database and then later try to restore it, you might get a message that the database is in a restoring state. Here is how you can fix this. Read More

By

Fixing “Microsoft.Net.Compilers is only supported on MSBuild v16.3 and above” Error

Quick and easy fix for MSBuild errors. Read More

By

Installing WordPress from the Command Line

How to install WordPress from the command line in Linux.

Read More

By

Using Microsoft Office MIME Types with MailKit

Recently I had problems with attaching a macro-enabled Excel workbook to an email. When it was received, the macro’s didn’t run correctly on the latest version of Microsoft Office. It did run correctly on Excel 2007. The workbook was being corrupted in the encoding into the email or decoding when its downloaded.

The following code will maintain the integrity of the Excel workbook when attached to an e-mail:

ContentType xlsmContent = new ContentType ("application/vnd.ms-excel.sheet.macroEnabled.12", "octet-steam");
builder.Attachments.Add ($"{Directory.GetCurrentDirectory ()}/Temp/workbook.xlsm", xlsmContent);

These are the MIME types for documents in Microsoft Office:

Ext MIME Type
.doc application/msword
.dot application/msword
.docx application/vnd.openxmlformats-officedocument.wordprocessingml.document
.dotx application/vnd.openxmlformats-officedocument.wordprocessingml.template
.docm application/vnd.ms-word.document.macroEnabled.12
.dotm application/vnd.ms-word.template.macroEnabled.12
.xls application/vnd.ms-excel
.xlt application/vnd.ms-excel
.xla application/vnd.ms-excel
.xlsx application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
.xltx application/vnd.openxmlformats-officedocument.spreadsheetml.template
.xlsm application/vnd.ms-excel.sheet.macroEnabled.12
.xltm application/vnd.ms-excel.template.macroEnabled.12
.xlam application/vnd.ms-excel.addin.macroEnabled.12
.xlsb application/vnd.ms-excel.sheet.binary.macroEnabled.12
.ppt application/vnd.ms-powerpoint
.pot application/vnd.ms-powerpoint
.pps application/vnd.ms-powerpoint
.ppa application/vnd.ms-powerpoint
.pptx application/vnd.openxmlformats-officedocument.presentationml.presentation
.potx application/vnd.openxmlformats-officedocument.presentationml.template
.ppsx application/vnd.openxmlformats-officedocument.presentationml.slideshow
.ppam application/vnd.ms-powerpoint.addin.macroEnabled.12
.pptm application/vnd.ms-powerpoint.presentation.macroEnabled.12
.potm application/vnd.ms-powerpoint.presentation.macroEnabled.12
.ppsm application/vnd.ms-powerpoint.slideshow.macroEnabled.12