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 76 77 78 79 80 81 82 83 84 85 86 87
| Option Explicit
Dim olapp As Object
Sub InitialisationOutlook()
On Error Resume Next: Set olapp = GetObject(, "Outlook.Application"): On Error GoTo 0
If olapp Is Nothing Then Set olapp = CreateObject("Outlook.Application")
End Sub
Sub EnvoiMail(ByVal Sujet As String, ByVal Corps As String, ByVal Destinataire As String, Optional Pj As String = "")
With olapp.CreateItem(0)
.Subject = Sujet
.Body = Corps
.To = Destinataire
If Pj <> "" Then .Attachments.Add Pj
.Send
End With
End Sub
Sub Transmission_Mail()
Dim UnSujet As String, UnDestinataire As String, UnCorps As String, UnePj As String
*
InitialisationOutlook
UnSujet = "Fiche du processus " & Feuil9.Range("A2").Value
UnDestinataire = Range("B7").Value
UnCorps = "Le xxx vous transmet la fiche de votre processus." & Chr(13) & Chr(13) & "En cas de désaccord avec les informations transmises, veuillez transmettre les correctifs au plus vite par mail uniquement à l'adresse suivante : xxxxx@gmail.com" & Chr(13) & Chr(13) & "En cas de non réponse de votre part sous 5 jours calendaires, la fiche sera considérée comme correcte." & Chr(13) & Chr(13) & Chr(13) & "Ci-joint la fiche concernant votre processus." & Chr(13) & Chr(13) & Chr(13) & "Respectueusement," & Chr(13) & "L'équipe xxx."
UnePj = sNomPdf
Call EnvoiMail(UnSujet, UnCorps, UnDestinataire, UnePj)
End Sub
Private Sub CommandButton2_Click() ' lancer automatisation du processus
Dim i As Integer
Dim j As Integer
Dim Trouve As Range
Dim PlageDeRecherche As Range
Dim Valeur_Cherchee As String
Dim AdresseTrouvee As String
Dim Lig As Integer
Dim Col As Integer
Dim Processus As String
Dim Imprim As String
Dim Mail As String
Dim AdrMail As String
AdrMail = ""
'ici le reste du code pour déclencher la synthese
' avant l'envoi mail dire - if Mail ="OUI" then...- lancer macro de l'envoi mail
If Mail = "Oui" Then
'Création du Pdf
Dim sNomPdf As String
Dim sDossier As String
Dim Destinataire As String
sDossier = ThisWorkbook.Path
sNomPdf = sDossier & "\" & "Synthese du processus " & Feuil9.Range("A2") & " _ Extraction du " & _
Replace(Replace(Replace(Left(Now, 16), ":", "h"), " ", " à "), "/", "-") & ".pdf"
Feuil9.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=sNomPdf, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
'Envoi du mail
Call Transmission_Mail
End If
'Procédure de demande d impression
If Imprim = "OUI" Then
ActiveWindow.SelectedSheets.PrintOut Copies:=NbreCopie
End If
'Affichage feuille
Application.ScreenUpdating = True
'Protection de la feuille
ActiveSheet.Protect
Range("A9").Select
End Sub |
Partager