Skip to content

Commit

Permalink
Feat 494 email (#1472)
Browse files Browse the repository at this point in the history
* docs: add english doc for email service

* docs: add norwegian doc for Email

* docs: refactor email docs after review comments

* docs: refactor email docs after review comments for the en-docs

---------

Co-authored-by: HauklandJ <[email protected]>
Co-authored-by: Eirik Mikkelsen <[email protected]>
  • Loading branch information
3 people authored Mar 20, 2024
1 parent ba15fb9 commit e258041
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
33 changes: 33 additions & 0 deletions content/app/development/configuration/email/_index.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: Email
description: How to create custom email notifications for apps.
weight: 400
---

## Activate generation of email notifications in your application

The email client is automatically added to the application. To use it, inject the `IEmailNotificationClient`-interface. The interface defines a method used to order an email notification from the [Altinn Notifications](https://github.com/Altinn/altinn-notifications) API.

### Code example
```csharp
using Altinn.App.Core.Internal.Email;
using Altinn.App.Core.Models.Email;
using Altinn.Platform.Storage.Interface.Models;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Altinn.App.Custom;

public class CustomEmailClass(IEmailNotificationClient emailNotificationClient)
{
private readonly IEmailNotificationClient _emailNotificationClient = emailNotificationClient;

public async Task OrderEmail(string subject, string body, List<EmailRecipient> emailRecipients, string sendersReference)
{
var emailNotification = new EmailNotification(subject, body, emailRecipients, sendersReference);
var emailOrderResponse = await _emailNotificationClient.Order(emailNotification, new System.Threading.CancellationToken());
...
}
}
```
33 changes: 33 additions & 0 deletions content/app/development/configuration/email/_index.nb.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: E-post
description: Hvordan opprette egendefinerte e-postvarslinger for apper.
weight: 400
---

## Aktiver generering av e-postvarslinger i applikasjonen din

E-postklienten legges automatisk til i applikasjonen. For å bruke den, injiser `IEmailNotificationClient`-interface. IEmailNotificationClient definerer en metode som brukes til å bestille en e-postvarsling fra [Altinn Notifications](https://github.com/Altinn/altinn-notifications) API.

### Kodeeksempel
```csharp
using Altinn.App.Core.Internal.Email;
using Altinn.App.Core.Models.Email;
using Altinn.Platform.Storage.Interface.Models;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Altinn.App.Custom;

public class CustomEmailClass(IEmailNotificationClient emailNotificationClient)
{
private readonly IEmailNotificationClient _emailNotificationClient = emailNotificationClient;

public async Task OrderEmail(string subject, string body, List<EmailRecipient> emailRecipients, string sendersReference)
{
var emailNotification = new EmailNotification(subject, body, emailRecipients, sendersReference);
var emailOrderResponse = await _emailNotificationClient.Order(emailNotification, new System.Threading.CancellationToken());
...
}
}
```

0 comments on commit e258041

Please sign in to comment.