/// <reference path="../pb_data/types.d.ts" />
onRecordAfterCreateSuccess((e) => {
  const nome = e.record.get("nome");
  const email = e.record.get("email");
  const telefone = e.record.get("telefone");
  const mensagem = e.record.get("mensagem");
  
  const message = new MailerMessage({
    from: {
      address: $app.settings().meta.senderAddress,
      name: $app.settings().meta.senderName
    },
    to: [{ address: "lcpvaluation@gmail.com" }],
    subject: "New Contact Form Submission from " + nome,
    html: "<h2>New Contact Form Submission</h2>" +
          "<p><strong>Name:</strong> " + nome + "</p>" +
          "<p><strong>Email:</strong> " + email + "</p>" +
          "<p><strong>Phone:</strong> " + (telefone || "Not provided") + "</p>" +
          "<p><strong>Message:</strong></p>" +
          "<p>" + mensagem + "</p>"
  });
  $app.newMailClient().send(message);
  e.next();
}, "contatos");