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
| 'Requete d'extraction des H24 pour insertion dans le mail
Dim qry3 As DAO.QueryDef
Dim sSQL3 As String
Dim rst3 As DAO.Recordset
sSQL3 = "SELECT T_employe_TMP.Coche_TMP, T_employe_TMP.Coche_H24_TMP, T_employe_TMP.Matricule_TMP, T_employe_TMP.IGG_TMP, T_employe_TMP.NOM_TMP, T_employe_TMP.PRENOM_TMP, T_employe_TMP.SERVICE_TMP, T_employe_TMP.SOCIETE_TMP" & _
" FROM T_employe_TMP" & _
" WHERE T_employe_TMP.Coche_H24_TMP;"
Set dbs = CurrentDb
Set rst3 = dbs.OpenRecordset(sSQL3, dbOpenSnapshot)
'ci-dessous test de la requete avec affichage
' Set qry3 = CurrentDb.CreateQueryDef("MaRequête_H24", sSQL3)
' affiche la requete pour controle
DoCmd.OpenQuery ("MaRequête_H24")
'Création du mail
Dim OutApp As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Recipient
Dim Recipients As Recipients
Set OutApp = CreateObject("Outlook.Application")
Set objOutlookMsg = OutApp.CreateItem(olMailItem)
'destinataire
Set Recipients = objOutlookMsg.Recipients
Set objOutlookRecip = Recipients.Add(Vmail_demandeur) 'mail du demandeur
'copie
objOutlookMsg.CC = Vmail_valideur & ";" & "toto@free.com" 'mail valideur et astreinte en copie
objOutlookRecip.Type = 1
'expéditeur
objOutlookMsg.SentOnBehalfOfName = "toto@free.com" ' insertion de l'adresse expéditrice
'niveau d'importance
objOutlookMsg.Importance = olImportanceHigh
'objet du mail
objOutlookMsg.Subject = " Votre demande d'accès HHE du : " & Vdate_demande & " pour le week-end du : " _
& Vdate_debut & " au " & Vdate_fin ' objet avec intégration des éléments
'création du corps de texte
objOutlookMsg.HTMLBody = objOutlookMsg.HTMLBody & "Bonjour<br>"
objOutlookMsg.HTMLBody = objOutlookMsg.HTMLBody & "<br>"
objOutlookMsg.HTMLBody = objOutlookMsg.HTMLBody & "Votre demande est prise en compte sous le n°: " & Me.txt_ID_demande.Value & "<br>"
objOutlookMsg.HTMLBody = objOutlookMsg.HTMLBody & "Celui-ci est à rappeler pour tout échange inhérent à cette demande<br>"
objOutlookMsg.HTMLBody = objOutlookMsg.HTMLBody & "<br>"
objOutlookMsg.HTMLBody = objOutlookMsg.HTMLBody & "Vous trouverez en pièce joint le mail initial<br>"
objOutlookMsg.HTMLBody = objOutlookMsg.HTMLBody & "<br>"
objOutlookMsg.HTMLBody = objOutlookMsg.HTMLBody & "<br>"
If sSQL3 <> "" Then 'si la requete n'est pas vide.
objOutlookMsg.HTMLBody = objOutlookMsg.HTMLBody & "Les personnes ci-dessous n'ont pas été ajoutées à la liste HHE,<br>"
objOutlookMsg.HTMLBody = objOutlookMsg.HTMLBody & "elles possèdent l'accès H24 pour l'immeuble demandé<br>"
objOutlookMsg.HTMLBody = objOutlookMsg.HTMLBody & sSQL3 "<br />"
End If
objOutlookMsg.HTMLBody = objOutlookMsg.HTMLBody & "<br>"
objOutlookMsg.HTMLBody = objOutlookMsg.HTMLBody & "<br>"
objOutlookMsg.HTMLBody = objOutlookMsg.HTMLBody & "<br>"
objOutlookMsg.HTMLBody = objOutlookMsg.HTMLBody & "<br>"
objOutlookMsg.HTMLBody = objOutlookMsg.HTMLBody & "Bien cordialement<br>"
objOutlookMsg.HTMLBody = objOutlookMsg.HTMLBody & "<br>"
objOutlookMsg.HTMLBody = objOutlookMsg.HTMLBody & "Astreinte<br>"
objOutlookMsg.HTMLBody = objOutlookMsg.HTMLBody & "<FONT color=#FF0000> 00 00 00 00 00 </FONT><br>"
objOutlookMsg.HTMLBody = objOutlookMsg.HTMLBody & "<br>"
objOutlookMsg.HTMLBody = objOutlookMsg.HTMLBody & "Tour X<br>"
objOutlookMsg.HTMLBody = objOutlookMsg.HTMLBody & "<FONT color=#FF0000> *Dans le cadre du RGPD, vos données (nom, prénom, matricule) sont conservées une année dans un fichier Excel avant dêtre supprimées.</FONT><br>"
objOutlookMsg.HTMLBody = objOutlookMsg.HTMLBody & "<br>"
objOutlookMsg.HTMLBody = objOutlookMsg.HTMLBody & "<img alt="html logo ODM" src="c:\ Outils\ODM\Fichiers de travail\Images\ODM.png" width="214" height="50" />"<br >"
objOutlookMsg.HTMLBody = objOutlookMsg.HTMLBody & "<br>"
For Each objOutlookRecip In objOutlookMsg.Recipients
objOutlookRecip.Resolve
Next
'objOutlookMsg.Send ' envoi le mai directement sans prévisuel
objOutlookMsg.Display ' ouvre le mail avant envoi
Set OutApp = Nothing
'Ci-dessous vidage des coches de la table T_employe_TMP
Dim UpSQL As String
UpSQL = "UPDATE T_employe_TMP SET Coche_TMP = false, Coche_H24_TMP = false;"
CurrentDb.Execute UpSQL, dbFailOnError
'Fermeture et libération des variables objet
rst1.Close
rst2.Close
Set rst1 = Nothing
Set rst2 = Nothing
Set dbs = Nothing
MsgBox "Demande enregistrée", , "Création Demande HHE"
'neutralise le bouton enregistrer pour éviter un doublon
but_valider.Enabled = False
End Sub |
Partager