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
|
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
'By Oliv' 29/06/2007 pour Outlook 2003, modifié pour Outlook 2013 (Vynmarius) 2015/06/09
Dim myRecipient As Outlook.Recipient
If Not Item.Class = olMail Then GoTo fin
Dim prompt As String
' ici renseigner le destinataire CCI automatique
cci = "moi@monmail.com"
Set myRecipient = Item.Recipients.Add(cci) 'ajout automatique au champ cci
myRecipient.Type = olBCC
myRecipient.Resolve
If myRecipient.Resolved = False Then
MsgBox "L'adresse Email n'est pas correcte !", vbCritical, "Erreur"
Cancel = True
End If
' ici renseigner le destinataire CC/CCI conditionnel
cci2 = "monboss@sonmail.com"
'commentez / dé-commentez au choix l'option voulue / non voulue
'########################Option CCI############################
prompt = "Ajouter le cci " & cci2 & " à " & Item.Subject & "?"
If MsgBox(prompt, vbYesNo + vbQuestion, "Sample") = vbYes Then
Set myRecipient = Item.Recipients.Add(cci2) ' ajout au champ cci, sous condition
myRecipient.Type = olBCC
myRecipient.Resolve
If myRecipient.Resolved = False Then
MsgBox "L'adresse Email n'est pas correcte !", vbCritical, "Erreur"
Cancel = True
End If
End If
'########################Option CC##############################
'prompt = "Ajouter le cc " & cci2 & " à " & Item.Subject & "?"
'If MsgBox(prompt, vbYesNo + vbQuestion, "Sample") = vbYes Then
'Set myRecipient = Item.Recipients.Add(cci2) ' ajout au champ cc, sous condition
'myRecipient.Type = olCC
'myRecipient.Resolve
'If myRecipient.Resolved = False Then
'MsgBox "L'adresse Email n'est pas correcte !", vbCritical, "Erreur"
'Cancel = True
'End If
'End If
'#######################FIN#####################################
fin:
End Sub |
Partager