1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
| Dim strFichier As Variant
Dim strFichierPDF As Variant
Dim strEtat As String
Dim strFiltre As String
Dim strMessageType As String
Dim strTitre As String
Dim strMsgg As String
Dim stemail As String
' Nom de l'état à imprimer
strEtat = "AF0"
Me.Refresh
mail0 = 0
imprimer0 = 0
cheminattestation = listeattestation.Column(2)
If DateAF <> 0 Then
RefreshQuery
Dim Qdf As QueryDef
Dim rst As Recordset
Set Qdf = CurrentDb.QueryDefs("recherAF_ETAT")
Qdf.Parameters("[Forms]![Moteur de recherche AF]![num_appel]").Value = [Forms]![Moteur de recherche AF]![num_appel]
Qdf.Parameters("[Forms]![Moteur de recherche AF]![cumuldesappel]").Value = [Forms]![Moteur de recherche AF]![cumuldesappel]
Qdf.Parameters("[Forms]![Moteur de recherche AF]![cmbRechNOMOPERATION]").Value = [Forms]![Moteur de recherche AF]![cmbRechNOMOPERATION]
Set rst = Qdf.OpenRecordset
' Parcourir toute la liste
While Not rst.EOF
' crée new dossier
If Dir(GetDbPathOfLinkedTable("tblAdmin") & "DOC\" & cmbRechNOMOPERATION & "\CLIENT\" & rst("NUM_LOGE"), vbDirectory) = "" Then
MkDir GetDbPathOfLinkedTable("tblAdmin") & "DOC\" & cmbRechNOMOPERATION & "\CLIENT\" & rst("NUM_LOGE")
Else
End If
' Nom de base du fichier PDF à crée
strFichier = Array(GetDbPathOfLinkedTable("tblAdmin") & "DOC\" & cmbRechNOMOPERATION & "\CLIENT\" & rst("NUM_LOGE") & "\" & "Appel de fonds " & rst("NUM_LOGE") & " " & Forms![Moteur de recherche AF]![num_appel] & ".pdf")
Texte66 = strFichier
'Le nom du fichier varie en fonction de la personne
strFichierPDF = StringFormat(strFichier(0), _
rst("NUM_LOGE"), _
rst("NUM_CLIENT"), _
rst("mailc"))
' Construire le filtre
strFiltre = "[NUM_LOGE] = '" & rst("NUM_LOGE") & "'"
' Imprimer l'état en le filtrant sur la personne concernée
PrintAsPDF strFichierPDF, strEtat, strFiltre, False
If rst("mailc") <> "" Then
mail0 = mail0 + 1
' module envoyé mail
' Titre du message
strTitre = "Appel de fonds résidence "
' Message type à expédier
' Les signes {...} seront remplacés plus loin par
' les infos Client
strMessageType = "Bonjour ," _
& vbCrLf & vbCrLf _
& "Veuillez trouver ci-joint votre convocation des examens," _
& " " _
& vbCrLf & "Je vous prie d'agréer, Madame/ Monsieur, l'expression de mes cordiales salutations." _
& vbCrLf & vbCrLf & "AAAAAA."
' Construire un message personnalisé
' (on remplace chaque {...} du message par les champs
' équivalents de la requête
strMsgg = strMessageType
' strMsgg = Replace(strMsg, "{Nom Client}", rst("NUM_CLIENT"))
' strMsgg = Replace(strMsg, "{Prénom Client}", rst("Titre"))
' Expédier le mail
strmail = rst("mailc")
SendOLMail2 strmail, strTitre, strMsgg, False, strFichier
' j'ai testé aussi
' SendOLMail2 strmail, strTitre, strMsgg, False, strFichier(0)
End If
' Personne suivante
rst.MoveNext
Wend
' Terminé !
rst.Close
Set rst = Nothing
MsgBox "Opération terminée !", vbInformation
Else
MsgBox "Merci de rentre un date pour l'appel de fond"
End If |
Partager