Send mail with attachments from different tables
Hi !
I would like to know how can I send by email, as an attachment, the documents for lines 29, 40 and 51?
The "Documents" table is not linked in N:1
---
Générer les textes
---;
let nomFacture := "Facture n°" + 'N° de transaction' + ".pdf";
let nomAnnexe := "Annexe à la facture n°" + 'N° de transaction' + ".pdf";
let nomJustifPaiement := "Justificatif de paiement de la facture n°" + 'N° de transaction' + ".pdf";
let FormulationMail := "Bonjour " + Compte.'Prénom' +
",<br><br>Veuillez trouver ci-jointe votre facture.<br><br>" +
Entreprise.'Signature des emails';
let ObjetMail := "Votre facture n°" + 'N° de transaction';
---
Enregistrer l'échange
---;
let me := this;
let newRecEchange := (create 'Échanges');
newRecEchange.(Compte := me.Compte);
newRecEchange.('Type de contact' := 2);
newRecEchange.('Canal de contact' := 2);
newRecEchange.(Type := 6);
newRecEchange.(Titre := ObjetMail);
newRecEchange.(Commentaires := FormulationMail);
---
Ajouter la facture en pièces jointes à l'échange
---;
let AddDocFacture := (create Documents);
AddDocFacture.('Échanges' := newRecEchange);
AddDocFacture.(Compte := me.Compte);
AddDocFacture.('Activités' := me.'Activités');
AddDocFacture.(Document := importFile(this, printAndSaveRecord(me, "Facture_template_dynamique"), nomAnnexe));
AddDocFacture.('Nom du document' := nomFacture);
AddDocFacture.('Type de document' := 5);
AddDocFacture.('Date de création' := today());
---
Ajouter l'annexe en pièces jointes à l'échange
---;
let AddDocAnnexe := (create Documents);
AddDocAnnexe.('Échanges' := newRecEchange);
AddDocAnnexe.(Compte := me.Compte);
AddDocAnnexe.('Activités' := me.'Activités');
AddDocAnnexe.(Document := importFile(this, printAndSaveRecord(me, "Annexe_facture_template_dynamique"), nomAnnexe));
AddDocAnnexe.('Nom du document' := nomAnnexe);
AddDocAnnexe.('Type de document' := 5);
AddDocAnnexe.('Date de création' := today());
---
Ajouter le justificatif de paiement en pièces jointes à l'échange
---;
let AddDocJustifPaiement := (create Documents);
AddDocJustifPaiement.('Échanges' := newRecEchange);
AddDocJustifPaiement.(Compte := me.Compte);
AddDocJustifPaiement.('Activités' := me.'Activités');
AddDocJustifPaiement.(Document := importFile(this, printAndSaveRecord(me, "Paiement_facture_template_dynamique"), nomJustifPaiement));
AddDocJustifPaiement.('Nom du document' := nomJustifPaiement);
AddDocJustifPaiement.('Type de document' := 5);
AddDocJustifPaiement.('Date de création' := today());
---
Envoyer par email
---;
sendEmail({
from: "test@mail.fr",
to: Compte.'E-mail principal',
cc: Compte.'E-mail secondaire',
subject: ObjetMail,
text: FormulationMail,
html: FormulationMail,
attachments: [Line29, Line40, Line51]
})
Thanks !
6 replies
-
You can select attachments from another table like this:
let attachment := first((select Tablex).attachmentfield)
see https://forum.ninox.com/t/x2h7fm9/send-emails-with-pictures-in-the-body-and-also-with-attachments-of-your-choice for an example database.
-
I again need help attaching attachments to an email.
For some emails, I have documents in image fields that I manage to integrate without any problem.
For other emails, I retrieve all documents from 1:N related records.
On the other hand, I can't manage to attach both documents by retrieving them directly in an image field AND all the documents of the linked records.
let attCGV := if 'Modèle'.CGV then Compte.Entreprise.'Conditions Générales de Vente' end; let attDonnees := if 'Modèle'.'Données personnelles' then Compte.Entreprise.'Traitement des données personnelles' end; let attSante := if 'Modèle'.'Données de santé' then Compte.Entreprise.'Traitement des données de santé' end; let attDocs := 'Documents 1:N'.Document; let attTotal := [attCGV, attDonnees, attSante, attDocs]; sendEmail({ from: Expediteur, to: 'Destinataire principal', cc: 'Destinataire en copie', bcc: 'Destinataire en copie cachée', subject: Sujet, text: 'Résumé', html: Commentaires, attachments: attTotal }); 'Envoyé' := true
In this example of a button intended to send an email with attachments, attCGV, attData and attSante correspond to documents retrieved from image fields‧
attDocs matches all documents in image fields for 1:N related records
It does not seem possible, with this method, to take into account attCGV + attDonnees + attSante + attDocs because the result does not give the same type of data...
Is there a way around this?
Content aside
- Status Answered
- 1 yr agoLast active
- 6Replies
- 194Views
-
2
Following