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
| Sub add_timestamp()
'---------------------------------------------------------------------------------------
' Procedure : add_timestamp
' Author : Oliv
' Date : 28/11/2018
' Purpose : ajout un tampon date en HAUT DU MAIL
'---------------------------------------------------------------------------------------
'
Dim obj As Object
Dim Oitem As Outlook.MailItem
Dim MonTexteEnPlus
Dim OuCommenceAdresse, fin, BaliseBody, NbTiret, Separateur
'choix de l'élément ACTIF
Set obj = Application.ActiveWindow
If TypeOf obj Is Outlook.Inspector Then
Set obj = obj.CurrentItem
Else
Set obj = obj.Selection(1)
End If
If obj.Class <> olMail Then Exit Sub
Set Oitem = obj
MonTexteEnPlus = "[Mon_nom]" & "<br>" & Format(Now(), "dd/MM/YYYY h:mm:ss")
Select Case Oitem.BodyFormat
'ici on vérifie le format du message HTML OU BRUT ...
Case olFormatHTML:
Separateur = "<BR>"
NbTiret = 45
OuCommenceAdresse = InStr(1, Oitem.HTMLBody, "<BODY", vbTextCompare)
If OuCommenceAdresse > 0 Then
fin = InStr(OuCommenceAdresse + 5, Oitem.HTMLBody, ">") + 1
BaliseBody = Mid(Oitem.HTMLBody, OuCommenceAdresse, fin - OuCommenceAdresse)
Oitem.HTMLBody = Replace(Oitem.HTMLBody, BaliseBody, BaliseBody & "<font style='font-family: Tahoma ;font-size: 12pt ;color:red;font-style: italic;'>" & MonTexteEnPlus & "</font><BR>" _
& "<font style='font-family: Tahoma ;font-size: 12pt ;color:red;font-style: italic;'>" & String(NbTiret, "-") & "</font><BR><BR>", 1, 1, vbTextCompare)
Else:
Oitem.HTMLBody = "<font style='font-family: Tahoma ;font-size: 12pt ;color:red;font-style: italic;'>" & MonTexteEnPlus & _
"</font><BR>" & "<font style='font-family: Tahoma ;font-size: 12pt ;color:red;font-style: italic;'>" & String(NbTiret, "-") & "</font><BR><BR>" & Oitem.HTMLBody
End If
Case Else
Separateur = Chr(10)
NbTiret = 35
Oitem.Body = Replace(MonTexteEnPlus, "<br>", vbCr) & Chr(10) & String(NbTiret, "-") & Chr(10) & Chr(10) & Oitem.Body
End Select
Oitem.save
Set obj = Nothing
Set Oitem = Nothing
End Sub |
Partager