Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagec#
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 };

// add you key pair values.
 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@tcnoreply@tc.gc.ca",
     From = "AFCEMTOASystem-SystemeMTOAAFCE@tcnoreply@tc.gc.ca",
     UserId = 2757,
     UserName = "MTOA_USER",
     Language = "english",
     Attachements = attachments,
     NotificationTemplateName = "MD_USER_RPT_ACCEPTEDyour template name",
     Parameters = parameters,
     IsHtml = true
};

var notification = await emailNotificationManager.SendEmailNotification(emailNotification);