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
| Public publipostagePJ As Variant
Sub setPublipostage()
On Error Resume Next
If publipostagePJ(0) = "" Then publipostagePJ = Array("fin", "fin", "fin", "fin", "fin", "fin", "fin", "fin", "fin", "fin")
While publipostagePJ(i) <> "fin"
contenu = contenu & vbCr & publipostagePJ(i)
i = i + 1
Wend
If InStr(1, item.Body, "#PJ=", vbTextCompare) > 0 Then
PJ = Split(Split(item.Body, "#PJ=", -1, vbTextCompare)(1), Chr(13))(0)
Set objOutlookRecip = item.Recipients.add(CC)
objOutlookRecip.Type = olCC
objOutlookRecip.Resolve
'on supprime la ligne
If item.BodyFormat = olFormatHTML Then
item.HTMLBody = Replace(item.HTMLBody, "#PJ=" & PJ, "", , , vbTextCompare)
Else
item.Body = Replace(item.Body, "#PJ=" & PJ, "", , , vbTextCompare)
End If
If InStr(1, Item.Body, "PJ", vbTextCompare) > 0 Then
If Item.Attachments.Count = 0 Then
answer = MsgBox("Pas de PJ, envoyer quand même*?", vbYesNo)
If answer = vbNo Then Cancel = True
End If
End If
End If
If "" = Dir(PJ, vbNormal) Then GoTo quest
publipostagePJ(i) = PJ
Else: Exit For
End If
Next i
End If
MsgBox "Votre publipostage doit comporter le terme :" & vbCr &
"PUBLIPOSTAGE" & vbCr & "dans le sujet." & vbCr &
"Celui-ci sera retiré lors de l'envoi"
End Sub |
Partager