magic.lambda.mime 10.0.18

Install-Package magic.lambda.mime -Version 10.0.18
dotnet add package magic.lambda.mime --version 10.0.18
<PackageReference Include="magic.lambda.mime" Version="10.0.18" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add magic.lambda.mime --version 10.0.18
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: magic.lambda.mime, 10.0.18"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. 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=10.0.18

// Install magic.lambda.mime as a Cake Tool
#tool nuget:?package=magic.lambda.mime&version=10.0.18
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

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

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
10.0.18 0 1/17/2022
10.0.15 140 12/31/2021
10.0.14 93 12/28/2021
10.0.7 385 12/22/2021
10.0.5 194 12/18/2021
10.0.2 178 12/14/2021
10.0.0 175 12/6/2021
9.9.9 728 11/29/2021
9.9.8 52 11/27/2021
9.9.3 319 11/9/2021
9.9.2 262 11/4/2021
9.9.0 366 10/30/2021
9.8.9 283 10/29/2021
9.8.7 294 10/27/2021
9.8.6 270 10/27/2021
9.8.5 258 10/26/2021
9.8.0 609 10/20/2021
9.7.9 240 10/19/2021
9.7.5 706 10/14/2021
9.7.0 410 10/9/2021
9.6.6 130 8/14/2021
9.5.3 1,685 7/20/2021
9.2.0 2,211 5/26/2021
9.1.4 594 4/21/2021
9.1.0 456 4/14/2021
9.0.0 376 4/5/2021
8.9.9 429 3/30/2021
8.9.3 632 3/19/2021
8.9.2 442 1/29/2021
8.9.1 416 1/24/2021
8.9.0 468 1/22/2021
8.6.9 1,518 11/8/2020
8.6.6 804 11/2/2020
8.6.0 1,626 10/28/2020
8.5.0 797 10/23/2020
8.4.0 2,234 10/13/2020
8.3.1 1,167 10/5/2020
8.3.0 581 10/3/2020
8.2.2 932 9/26/2020
8.2.1 595 9/25/2020
8.2.0 518 9/25/2020
8.1.18 203 9/24/2020
8.1.17 2,967 9/13/2020
8.1.16 290 9/13/2020
8.1.15 830 9/12/2020
8.1.11 1,049 9/11/2020
8.1.10 579 9/6/2020
8.1.9 549 9/3/2020
8.1.8 642 9/2/2020
8.1.7 507 8/28/2020
8.1.4 509 8/25/2020
8.1.3 544 8/18/2020
8.1.2 527 8/16/2020
8.1.1 615 8/15/2020
8.1.0 263 8/15/2020
8.0.1 1,219 8/7/2020
8.0.0 530 8/7/2020
7.0.1 251 6/28/2020
7.0.0 960 6/28/2020
5.0.1 1,557 5/29/2020
5.0.0 247 5/29/2020