Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Description

Sends an email notification.

Package Details

Interface

IEmailNotificationManager

Syntax

Task<bool> SendEmailNotification(EmailNotificationDTO dto, bool overrideEmailRecipientsSafeguard = false)

Returns

Task<bool>

API Endpoint

POST

/api/v1/notifications

Parameters

Parameter

Description

Parameter Type

emailNotificationDTO

An object with email notification properties.

Request body

overrideEmailRecipientsSafeguard

Allow the email "IsEmailNotificationTestModeEnabled" setting to be ignored.

Query string

Sample request body

{
  "NotificationTemplateName": "string",
  "ServiceRequestId": 0,
  "UserId": 0,
  "UserName": "string",
  "Language": "string",
  "From": "string",
  "To": "string",
  "IsHtml": true,
  "Attachements": [
    {
      "Name": "string",
      "Type": "string",
      "Sream": {
        "__identity": {}
      },
      "AttachmentBytes": "string"
    }
  ],
  "Parameters": [
    {
      "key": "string",
      "value": "string"
    }
  ]
}

Return

200 OK if successful.

400 Bad Request - If it failed.

Example

const int serviceRequestId = 41;
const string testString = "04/01/2010 00:00,1.4314,1.4316";
var encoding = new UTF8Encoding();
var testArray = encoding.GetBytes(testString);

//Create Attachment
var attach = new EmailAttachmentDTO
{
    Name = $"366125_{serviceRequestId.ToString()}.pdf",
    Type = ".pdf",
    Sream = new MemoryStream(testArray),
    AttachmentBytes = testArray
 };
 var attachments = new List<EmailAttachmentDTO> { attach };
 var parameters = new List<KeyValuePair<string, string>>()
 {
     new KeyValuePair<string, string>("LICENCE-NUMBER",  "366125"),
     new KeyValuePair<string, string>("REFERENCE-ID", serviceRequestId.ToString()),
     new KeyValuePair<string, string>("MONITOR-NAME", "John Smith"),
     new KeyValuePair<string, string>("MONITOR-DATE", "2018-12-31"),
     new KeyValuePair<string, string>("REGION-EMAIL-ADDRESS", "AFCEMTOASystem-SystemeMTOAAFCE@tc.gc.ca"),
     new KeyValuePair<string, string>("COMMENT", "This is my comment")
 };
 var emailNotification = new EmailNotificationDTO
 {
     ServiceRequestId = serviceRequestId,
     To = "AFCEMTOASystem-SystemeMTOAAFCE@tc.gc.ca",
     From = "AFCEMTOASystem-SystemeMTOAAFCE@tc.gc.ca",
     UserId = 2757,
     UserName = "MTOA_USER",
     Language = "english",
     Attachements = attachments,
     NotificationTemplateName = "MD_USER_RPT_ACCEPTED",
     Parameters = parameters,
     IsHtml = true
};

var notification = await emailNotificationManager.SendEmailNotification(emailNotification);
  • No labels