Almostengr.CrimeMappingCom.EmailParser 9.2026.3.803

dotnet add package Almostengr.CrimeMappingCom.EmailParser --version 9.2026.3.803
                    
NuGet\Install-Package Almostengr.CrimeMappingCom.EmailParser -Version 9.2026.3.803
                    
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="Almostengr.CrimeMappingCom.EmailParser" Version="9.2026.3.803" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Almostengr.CrimeMappingCom.EmailParser" Version="9.2026.3.803" />
                    
Directory.Packages.props
<PackageReference Include="Almostengr.CrimeMappingCom.EmailParser" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Almostengr.CrimeMappingCom.EmailParser --version 9.2026.3.803
                    
#r "nuget: Almostengr.CrimeMappingCom.EmailParser, 9.2026.3.803"
                    
#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.
#:package Almostengr.CrimeMappingCom.EmailParser@9.2026.3.803
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Almostengr.CrimeMappingCom.EmailParser&version=9.2026.3.803
                    
Install as a Cake Addin
#tool nuget:?package=Almostengr.CrimeMappingCom.EmailParser&version=9.2026.3.803
                    
Install as a Cake Tool

CrimeMapping.com Email Parser

Table of Contents

Description

Read email alerts that have been received from the CrimeMapping.com website. This library is designed to read plain text emails that are sent from the site.

Crimemapping.com does not provide an API to retrive the information that is available on their website. They do allow for users to subscribe to email alerts that are sent from the website. When subscribimg to the email alerts, the same email address can be used to receive mutliple alerts to the same email address.

This library allows you to parse those emails in your C# application and save them in JSON format for use within your application.

Installation

Using the terminal, navigate to your project's application directory. Then run the commands below.

dotnet add package Almostengr.CrimeMappingCom.EmailParser
dotnet restore

The package will download and install.

Usage

appsettings.json

Add the below to your appsettings.json file. This file is used to configure the library and its functions.

{
    "CrimeMappingSettings": { 
        "Hostname": "mail.example.com",
        "Username" : "emailuser",
        "Password":  "emailpass",
        "PortNumber": 993,
        "OutputDirectory" : "/home/almostengr/crimedata",
    }
}
Hostname

The address of the email server that will be receiving the email alerts.

Username

The username of the account that will be receiving the email alerts.

Password

The password of the email account that will be receiving the email alerts.

PortNumber

The port number of the server that should be used to connect to the email server.

OutputDirectory

The location on the file system, that the json files will be written to for further use.

With Dependency Injection

In the Program.cs file, add the below to include all services within this library.

builder.Services.AddCrimeMappingServices(builder.Configuration);

In your service method or class, added the below code to read all of the unread emails.

List<(MimeMessage, MailKit.UniqueId)> emails = await _imapEmailReader.GetUnreadAsync();
List<MailKit.UniqueId> processedMessageIds = new();
foreach (var (email, uid) in emails)
{
    try
    {
        var alert = _crimeEmailParser.Parse(email.TextBody);
        foreach (var crime in alert.Incidents)
        {
            _jsonCrimeWriter.Write(crime);
        }
        processedMessageIds.Add(uid);
    }
    catch (Exception ex)
    {
        _logger.LogError(ex.Message);
        continue;
    }
}

await _imapEmailReader.MarkReadAsync(processedMessageIds);

Json files will be created for each of the incidents that was found in each of the emails.

Contributions

To contribute, you may

  • create an issue using the appropriate template on the project repository.
  • create a pull request with your code changes to the project repository.

Project Repository

https://github.com/almostengr/Almostengr.CrimeMappingCom.EmailParser

License

GNU GENERAL PUBLIC LICENSE. See LICENSE for more details.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
9.2026.3.803 133 3/8/2026