• Stars
    star
    168
  • Rank 225,507 (Top 5 %)
  • Language
    C#
  • Created over 9 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A .NET library to make MSG files without the need for Outlook

What is MsgKit?

MsgKit is a 100% managed C# .NET library that supports C# .NET 4.6.2 and Standard 2.0 (no PINVOKE or whatsoever) which may be used for the creation of messages (E-Mail, Appointments, Journals and Stickey Notes) that are Outlook compatible

License Information

MsgKit is Copyright (C) 2015-2023 Magic-Sessions and is licensed under the MIT license:

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Installing via NuGet

NuGet

The easiest way to install MsgKit is via NuGet.

In Visual Studio's Package Manager Console, simply enter the following command:

Install-Package MsgKit 

Creating an e-mail

using (var email = new Email(
        new Sender("[email protected]", "Peter Pan"),
        new Representing("[email protected]", "Tinkerbell"),
        "Hello Neverland subject"))
{
    email.Recipients.AddTo("[email protected]", "Captain Hook");
    email.Recipients.AddCc("[email protected]", "The evil ticking crocodile");
    email.Subject = "This is the subject";
    email.BodyText = "Hello Neverland text";
    email.BodyHtml = "<html><head></head><body><b>Hello Neverland html</b></body></html>";
    email.Importance = MessageImportance.IMPORTANCE_HIGH;
    email.IconIndex = MessageIconIndex.ReadMail;
    email.Attachments.Add(@"d:\crocodile.jpg");
    email.Save(@"c:\email.msg");

    // Show the E-mail
    System.Diagnostics.Process.Start(@"c:\email.msg");
}

Creating an Appointment

using (var appointment = new Appointment(
    new Sender("[email protected]", "Peter Pan"),
    new Representing("[email protected]", "Tinkerbell"),
    "Hello Neverland subject")) 
{
    appointment.Recipients.AddTo("[email protected]", "Captain Hook");
    appointment.Recipients.AddCc("[email protected]", "The evil ticking crocodile");
    appointment.Subject = "This is the subject";
    appointment.Location = "Neverland";
    appointment.MeetingStart = DateTime.Now.Date;
    appointment.MeetingEnd = DateTime.Now.Date.AddDays(1).Date;
    appointment.AllDay = true;
    appointment.BodyText = "Hello Neverland text";
    appointment.BodyHtml = "<html><head></head><body><b>Hello Neverland html</b></body></html>";
    appointment.SentOn = DateTime.UtcNow;
    appointment.Importance = MessageImportance.IMPORTANCE_NORMAL;
    appointment.IconIndex = MessageIconIndex.UnsentMail;
    appointment.Attachments.Add(@"d:\crocodile.jpg");
    appointment.Save(@"c:\appointment.msg");

    // Show the Appointment
    System.Diagnostics.Process.Start(@"c:\appointment.msg");
}

Creating a contact card

using (var contact = new Contact(
    new Sender(SenderTextBox.Text, string.Empty),
    SubjectTextBox.Text,
    DraftMessageCheckBox.Checked,
    ReadReceiptCheckBox.Checked))
{
    contact.Recipients.AddTo("[email protected]", "Captain Hook");
    contact.Recipients.AddCc("[email protected]", "The evil ticking crocodile");
    contact.Subject = "This is the subject";
    contact.BodyText = "Hello Neverland text";
    contact.BodyHtml = "<html><head></head><body><b>Hello Neverland html</b></body></html>"
    contact.Importance = MessageImportance.IMPORTANCE_NORMAL;
    contact.FileUnder = "File under";
    contact.InstantMessagingAddress = "Instant messaging address";
    contact.Private = false;
    contact.BirthDay = DateTime.Now;
    contact.WeddingAnniversary = DateTime.Now;
    contact.Assistant = new ContactAssistant {Name = "Assistant name", TelephoneNumber = "Assistant telephone number"};
    contact.CallBackTelePhoneNumber = "callback telephone number";
    contact.CarTelePhoneNumber = "car telephone number";
    contact.ChildrensNames = new List<string> {"First child name", "Second child name", "Third child name"};
    contact.CompanyMain = new ContactCompanyMain { Name = "Company main name", TelephoneNumber = "Company main telephone number"};
    contact.DepartmentName = "Department name";
    contact.Generation = "Generation";
    contact.GivenName = "GivenName";
    contact.Initials = "Initials";
    contact.ISDNNumber = "ISDN number";
    contact.Language = "Language";
    contact.Location = "Location";
    contact.ManagerName = "Manager name";
    contact.MiddleName = "Middle name";
    contact.MobileTelephoneNumber = "Mobile telephone number";
    contact.NickName = "Nick name";
    contact.OfficeLocation = "Office location";
    contact.PersonalHomePage = "Personal home-page";
    contact.PostalAddress = "Postal address";
    contact.PrimaryFaxNumber = "Primary fax number";
    contact.PrimaryTelephoneNumber = "Primary telephone number";
    contact.Profession = "Profession";
    contact.RadioTelephoneNumber = "Radio telephone number";
    contact.SpouseName = "Spouse name";
    contact.SurName = "Sur name";
    contact.TelexNumber = "Telex number";
    contact.Title = "Title";
    contact.TTYTDDPhoneNumber = "TTYTDD phone number";
    contact.Email1 = new Address("[email protected]", "email1");
    contact.Email2 = new Address("[email protected]", "email2");
    contact.Email3 = new Address("[email protected]", "email3");
    //contact.Fax1 = "fax1@1234567890";
    //contact.Fax2 = "fax2@1234567890";
    //contact.Fax3 = "fax3@1234567890";
    contact.OfficeTelephoneNumber = "Office telephone number";
    contact.InstantMessagingAddress = "Instant messaging address";
    contact.Yomi = new ContactYomi { CompanyName = "Yomi company name", FirstName = "Yomi first name", LastName = "Yomi last name"};

    contact.Work = new ContactWork
    {
        TelephoneNumber = "Contact telephone number",
        City = "Contact city",
        Country = "Contact country",
        CountryCode = "Contact country code",
        PostOfficeBox = "Contact post office box",
        PostalCode = "Contact postal code",
        Street = "Contact street",
        Address = "Contact\nBla bla\nBla die bla\nBLa die bla die bla"
    };

    contact.Business = new ContactBusiness
    {
        TelephoneNumber = "Business telephone number",
        FaxNumber = "Business fax number",
        HomePage = "Business home-page",
        City = "Business city",
        Country = "Business country",
        PostalCode = "Business postal code",
        State = "Business state",
        Street = "Business street",
        Address = "Business\nBla bla\nBla die bla\nBLa die bla die bla"
    };

    contact.Home = new ContactHome
    {
        TelephoneNumber = "Home telephone number",
        TelephoneNumber2 = "Home telephone number 2",
        FaxNumber = "Home faxnumber",
        City = "Home city",
        Country = "Home country",
        PostalCode = "Home postal code",
        State = "Home state",
        Street = "Home street",
        Address = "Home\nBla bla\nBla die bla\nBLa die bla die bla"
    };

    contact.Other = new ContactOther
    {
        TelephoneNumber = "Other telephone number",
        City = "Other city",
        Country = "Other country",
        PostalCode = "Other postal code",
        State = "Other state",
        Street = "Other street",
        Address = "Other\nBla bla\nBla die bla\nBLa die bla die bla"
    };

    contact.PagerTelephoneNumber = "Pager telephone number";
    contact.PostalAddressId = PostalAddressId.HOME_ADDRESS;

    contact.ContactPicture = File.ReadAllBytes("Images\\tinkerbell.jpg");
    contact.IconIndex = MessageIconIndex.UnsentMail;
    contact.Save("c:\\contact.msg");
    
    System.Diagnostics.Process.Start("c:\\contact.msg");
}

Core Team

Sicos1977 (Kees van Spelde)
Seeker25 (Travis Semple) - Implemented Appointment support

Support

If you like my work then please consider a donation as a thank you by using the donate button on the top

Reporting Bugs

Have a bug or a feature request? Please open a new issue.

Before opening a new issue, please search for existing issues to avoid submitting duplicates.