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
| Public Sub Liste_PJ_20131118()
'insère le nom des PJ dans le corps du message
Dim Courrier As MailItem
Dim NomsPJ As String
Dim NbPJ As Integer
Dim i As Integer
Dim pj As Attachment
Dim Separateur As Variant
Dim NbTiret As Integer
If Application.ActiveInspector Is Nothing Then Exit Sub
Set Courrier = ActiveInspector.CurrentItem
If Courrier Is Nothing Then Exit Sub
Select Case Courrier.BodyFormat
Case olFormatHTML:
Separateur = "<BR>"
NbTiret = 45
Case olFormatPlain:
Separateur = Chr(10)
NbTiret = 35
Case Else
Separateur = " - "
NbTiret = 50
End Select
NbPJ = Courrier.Attachments.Count
For i = NbPJ To 1 Step -1
Set pj = Courrier.Attachments(i)
NomsPJ = NomsPJ & Separateur & "- " & pj.FileName
Next
Select Case Courrier.BodyFormat
Case olFormatHTML:
OuCommenceAdresse = InStr(1, Courrier.HTMLBody, "<BODY", vbTextCompare)
If OuCommenceAdresse > 0 Then
fin = InStr(OuCommenceAdresse + 5, Courrier.HTMLBody, ">") + 1
BaliseBody = Mid(Courrier.HTMLBody, OuCommenceAdresse, fin - OuCommenceAdresse)
Courrier.HTMLBody = Replace(Courrier.HTMLBody, BaliseBody, BaliseBody & "<font style='font-family: Tahoma ;font-size: 8pt ;color:#808080;font-style: italic;'>" & NomsPJ & "</font><BR>" _
& "<font style='font-family: Tahoma ;font-size: 8pt ;color:#808080;font-style: italic;'>" & String(NbTiret, "-") & "</font><BR><BR>", 1, 1, vbTextCompare)
Else: Courrier.HTMLBody = "<font style='font-family: Tahoma ;font-size: 8pt ;color:#808080;font-style: italic;'>" & NomsPJ & _
"</font><BR>" & "<font style='font-family: Tahoma ;font-size: 8pt ;color:#808080;font-style: italic;'>" & String(NbTiret, "-") & "</font><BR><BR>" & Courrier.HTMLBody
End If
Case Else
Courrier.Body = NomsPJ & Chr(10) & String(NbTiret, "-") & Chr(10) & Chr(10) & Courrier.Body
End Select
' A activer pour enregistrer automatiquement les modifs
'Courrier.Save
End Sub |
Partager