magic.lambda.mime 11.0.5

There is a newer version of this package available.
See the version list below for details.
dotnet add package magic.lambda.mime --version 11.0.5                
NuGet\Install-Package magic.lambda.mime -Version 11.0.5                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="magic.lambda.mime" Version="11.0.5" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add magic.lambda.mime --version 11.0.5                
#r "nuget: magic.lambda.mime, 11.0.5"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install magic.lambda.mime as a Cake Addin
#addin nuget:?package=magic.lambda.mime&version=11.0.5

// Install magic.lambda.mime as a Cake Tool
#tool nuget:?package=magic.lambda.mime&version=11.0.5                

Parsing and creating MIME messages with Hyperlambda

magic.lambda.mime gives you the ability to parse and create MIME messages from Hyperlambda. The project contains the following slots.

  • [mime.parse] - Parses a MIME message, and returns it as a lambda object
  • [mime.create] - Creates a MIME message for you, and returns the entire message as text, being the MIME entity
  • [.mime.parse] - Parses a native MimeEntity for you, and returns it as a lambda object (not for usage directly from Hyperlambda code)
  • [.mime.create] - Creates a MIME message for you, and returns it as a native MimeEntity object (not for usage directly from Hyperlambda code)

Parsing MIME messages

Below is an example of how parsing a MIME message might look like.

// Actual message
.msg:"Content-Type: multipart/mixed; boundary=\"=-3O9TzEjuVDwt7d5uGDkV/Q==\"\n\n--=-3O9TzEjuVDwt7d5uGDkV/Q==\nContent-Type: text/plain\nContent-Disposition: attachment; filename=README.md\n\n# Your dynamic files folder\n\nSome README.md file\n\n--=-3O9TzEjuVDwt7d5uGDkV/Q==\nContent-Type: text/plain\n\nBar\n--=-3O9TzEjuVDwt7d5uGDkV/Q==--\n"

// Parsing the above message
mime.parse:x:@.msg

After evaluating the above, you'll end up with something resembling the following.

mime.parse:multipart/mixed
   entity:text/plain
      headers
         Content-Disposition:attachment; filename=README.md
      content:"# Your dynamic files folder\n\nSome README.md file\n"
   entity:text/plain
      content:Bar

Notice how the slot creates a tree structure, perfectly resembling your original MIME message. It will also take care of MIME headers for you, adding these into a [headers] collection, on a per MIME entity basis, depending upon whether or not your message actually contains headers or not. The [.mime.parse] semantically works identically, except it requires as its input a raw MimeEntity object from MimeKit. The [.mime.parse] slot can only be invoked from C#, since it starts with a ".".

Creating a mime message

The [mime.create] slot is logically the exact opposite of the [mime.parse] slot, and can take (almost) the exact same input as its sibling produces as output. Below is an example.

mime.create:multipart/mixed
   structured:false

   entity:text/plain
      content:this is the body text
      
   entity:text/plain
      content:this is another body text

Which of course wil result in something resembling the following after evaluation.

mime.create:"Content-Type: multipart/mixed; boundary=\"=-7+NI+p6PuOyQUzW5ihnXvw==\"\n\n--=-7+NI+p6PuOyQUzW5ihnXvw==\nContent-Type: text/plain\n\nthis is the body text\n--=-7+NI+p6PuOyQUzW5ihnXvw==\nContent-Type: text/plain\n\nthis is another body text\n--=-7+NI+p6PuOyQUzW5ihnXvw==--\n"

Notice - If you set its [structured] argument to boolean true, the slot will return the MIME envelope headers for the outermost MIME entity "detached" from the rest of the message. This is useful when you for some reasons don't want the headers for the outermost entity to be a part of the actual message, such as for instance when creating multipart/form-data types of messages you need to transmit to some HTTP endpoint. If you do this, the return after executing the slot will resemble the following.

mime.create
   Content-Type:"multipart/mixed; boundary=\"=-EbMBZ3eHrSrMqtB2KHSv+A==\""
   content:"--=-EbMBZ3eHrSrMqtB2KHSv+A==\nContent-Type: text/plain\n\nthis is the body text\n--=-EbMBZ3eHrSrMqtB2KHSv+A==\nContent-Type: text/plain\n\nthis is another body text\n--=-EbMBZ3eHrSrMqtB2KHSv+A==--\n"

The [.mime.create] slot, will semantically do the exact same thing, but instead of returning a piece of text, being the MIME message, it will produce a raw MimeEntity that it returns to caller. This slot is used internally when the "magic.lambda.mail" project constructs emails to send over an SMTP connection for instance, and when the "magic.lambda.http" project transmits multipart/form-data types of requests. This slot can only be invoked from C# since it starts with a period (.) as its name.

Project website

The source code for this repository can be found at github.com/polterguy/magic.lambda.mime, and you can provide feedback, provide bug reports, etc at the same place.

Quality gates

  • Build status
  • Quality Gate Status
  • Bugs
  • Code Smells
  • Coverage
  • Duplicated Lines (%)
  • Lines of Code
  • Maintainability Rating
  • Reliability Rating
  • Security Rating
  • Technical Debt
  • Vulnerabilities
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on magic.lambda.mime:

Package Downloads
magic.library

Helper project for Magic to wire up everything easily by simply adding one package, and invoking two simple methods. When using Magic, this is (probably) the only package you should actually add, since this package pulls in everything else you'll need automatically, and wires up everything sanely by default. To use package go to https://polterguy.github.io

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
17.2.0 459 1/22/2024
17.1.7 187 1/12/2024
17.1.6 150 1/11/2024
17.1.5 187 1/5/2024
17.0.1 197 1/1/2024
17.0.0 371 12/14/2023
16.11.5 315 11/12/2023
16.9.0 331 10/9/2023
16.7.0 558 7/11/2023
16.4.1 363 7/2/2023
16.4.0 358 6/22/2023
16.3.1 304 6/7/2023
16.3.0 315 5/28/2023
16.1.9 614 4/30/2023
15.10.11 460 4/13/2023
15.9.1 603 3/27/2023
15.9.0 449 3/24/2023
15.8.2 480 3/20/2023
15.7.0 391 3/6/2023
15.5.0 1,596 1/28/2023
15.2.0 636 1/18/2023
15.1.0 1,132 12/28/2022
14.5.7 688 12/13/2022
14.5.5 776 12/6/2022
14.5.1 650 11/23/2022
14.5.0 586 11/18/2022
14.4.5 682 10/22/2022
14.4.1 759 10/22/2022
14.4.0 649 10/17/2022
14.3.1 1,265 9/12/2022
14.3.0 613 9/10/2022
14.1.3 929 8/7/2022
14.1.2 649 8/7/2022
14.1.1 628 8/7/2022
14.0.14 672 7/26/2022
14.0.12 647 7/24/2022
14.0.11 625 7/23/2022
14.0.10 646 7/23/2022
14.0.9 637 7/23/2022
14.0.8 696 7/17/2022
14.0.5 786 7/11/2022
14.0.4 758 7/6/2022
14.0.3 716 7/2/2022
14.0.2 670 7/2/2022
14.0.0 823 6/25/2022
13.4.0 2,057 5/31/2022
13.3.4 1,443 5/9/2022
13.3.0 936 5/1/2022
13.2.0 1,153 4/21/2022
13.1.0 1,015 4/7/2022
13.0.0 705 4/5/2022
11.0.5 1,404 3/2/2022
11.0.4 751 2/22/2022
11.0.3 772 2/9/2022
11.0.2 788 2/6/2022
11.0.1 746 2/5/2022
10.0.21 745 1/28/2022
10.0.20 738 1/27/2022
10.0.19 763 1/23/2022
10.0.18 733 1/17/2022
10.0.15 931 12/31/2021
10.0.14 533 12/28/2021
10.0.7 1,489 12/22/2021
10.0.5 752 12/18/2021
10.0.2 651 12/14/2021
10.0.0 634 12/6/2021
9.9.9 1,020 11/29/2021
9.9.8 356 11/27/2021
9.9.3 1,085 11/9/2021
9.9.2 791 11/4/2021
9.9.0 896 10/30/2021
9.8.9 869 10/29/2021
9.8.7 841 10/27/2021
9.8.6 821 10/27/2021
9.8.5 888 10/26/2021
9.8.0 1,619 10/20/2021
9.7.9 757 10/19/2021
9.7.5 1,687 10/14/2021
9.7.0 1,092 10/9/2021
9.6.6 411 8/14/2021
9.5.3 3,654 7/20/2021
9.2.0 4,497 5/26/2021
9.1.4 1,475 4/21/2021
9.1.0 1,236 4/14/2021
9.0.0 1,061 4/5/2021
8.9.9 1,201 3/30/2021
8.9.3 1,723 3/19/2021
8.9.2 1,216 1/29/2021
8.9.1 1,238 1/24/2021
8.9.0 1,292 1/22/2021
8.6.9 3,136 11/8/2020
8.6.6 2,074 11/2/2020
8.6.0 4,209 10/28/2020
8.5.0 2,116 10/23/2020
8.4.0 5,706 10/13/2020
8.3.1 2,863 10/5/2020
8.3.0 1,449 10/3/2020
8.2.2 2,260 9/26/2020
8.2.1 1,497 9/25/2020
8.2.0 1,444 9/25/2020
8.1.18 512 9/24/2020
8.1.17 7,348 9/13/2020
8.1.16 581 9/13/2020
8.1.15 2,308 9/12/2020
8.1.11 2,698 9/11/2020
8.1.10 1,513 9/6/2020
8.1.9 1,489 9/3/2020
8.1.8 1,526 9/2/2020
8.1.7 1,377 8/28/2020
8.1.4 1,391 8/25/2020
8.1.3 1,513 8/18/2020
8.1.2 1,413 8/16/2020
8.1.1 1,437 8/15/2020
8.1.0 556 8/15/2020
8.0.1 3,055 8/7/2020
8.0.0 1,421 8/7/2020
7.0.1 543 6/28/2020
7.0.0 2,398 6/28/2020
5.0.1 3,774 5/29/2020
5.0.0 552 5/29/2020