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
| Public Sub SendOLMail( _
ByVal strDest As String, _
ByVal strObj As String, _
ByVal strMsg As String, _
ByVal blnEdit As Boolean, _
Optional ByVal avarFichiers As Variant)
Dim ol As Outlook.Application
Dim mi As Outlook.MailItem
Dim varPJ As Variant
On Error GoTo OLMailErr
Set ol = New Outlook.Application
Set mi = ol.CreateItem(olMailItem)
With mi
.To = strDest
.Subject = strObj
.Body = strMsg
.Attachments.Add "C:\Testmacro.xlsx"
If blnEdit Then
.Display
Else
.Send
End If
End With
Set mi = Nothing
Set ol = Nothing
Exit Sub
OLMailErr:
MsgBox "Erreur : " & Err.Number & vbCrLf & Err.Description
Exit Sub
End Sub
Private Sub Commande62_Click()
Dim astrFichiers(1 To 1) As String
astrFichiers(1) = "C:\Testmacro.xlsx"
If Me.[Franchiseur] = "XX" Then
'C'est la que je bloque : si Me.[Franchiseur] = "XX" est vrai, j'excécute l'envoi, si non je passe SendOLMail2 du suivant qui correspond, à un autre type de mess personnalisé, etc ...
SendOLMail Me.[EMAIL:], _
"Franchise xx", _
"Bonjour," & vbCrLf & "Je suis le consultant mandaté par xx pour le recrutement de ses franchisés." _
& vbCrLf & "J'ai bien reçu votre demande d'information concernant cette franchise." _
& vbCrLf & "Vous trouverez en PJ la plaquette commerciale de cette enseigne." _
& vbCrLf & "A réception du Questionnaire que vous trouverez en PJ, je vous contacterai par téléphone pour un premier entretien d'information." _
& vbCrLf & "A ce moment là, nous discuterons ensemble de vos possibilités pour réaliser ce projet." _
& vbCrLf & "Dans l'attente," _
& vbCrLf & "Cordialement." _
& vbCrLf & "xx", _
True, _
astrFichiers
End If
End Sub |
Partager