Bonjour à tous,
Je dois envoyer automatiquement des fichiers PDF par mail et j'ai réussi à tout mettre en place sauf le corps du message car il y a des variations sur le format (police, taille...) et une signature avec un logo.
J'ai pensé préparé mettre le texte et la signature (avec le logo) dans un document Word mais je ne sais pas comment récupérer le tout pour l'intégrer dans le corps du message.
Pourriez-vous me guider sur cette dernière étape ou même m'orienter vers une autre solution aboutissant au même résultat ?
Voici où j'en suis :
Merci pour votre aide et pour votre temps,
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Function Send_PDF() Dim db As DAO.Database Dim Civilite, Nom, eMail, Indice, DateJour As String Dim rs1 As DAO.Recordset DateJour = Right(Date, 4) & Mid(Date, 4, 2) & Left(Date, 2) Set db = Application.CurrentDb Set rs1 = db.OpenRecordset("Select * from SendPDF") Set fso = CreateObject("Scripting.FileSystemObject") If DCount("*", "SendPDF") > 0 Then rs1.MoveFirst Do While rs1.EOF = False Civilite = rs1("Civilite") Nom = rs1("Nom") eMail = rs1("eMail") Indice = rs1("Indice") Chemin = CurrentProject.Path & "/" & DateJour WaitSeconds (5) Set objMail = CreateObject("CDO.Message") Set fso = CreateObject("Scripting.FileSystemObject") objMail.From = "email@email.com" objMail.Subject = "Objet de l'e-Mail" objMail.To = eMail objMail.Cc = "boss@email.com" objMail.Bcc = "monemail@email.com" objMail.TextBody = Civilite & " " & Nom &"," & vbCrLf & vbCrLf & "Le texte de ma page Word avec la signature ou toute solution apportant le même résultat" objMail.AddAttachment (CurrentProject.Path & "\" & "monFichier1") objMail.AddAttachment (CurrentProject.Path & "\" & "Pdf\" & DateJour & "\" & Indice & "\" & Indice & "_CP.pdf") objMail.AddAttachment (CurrentProject.Path & "\" & "Pdf\" & DateJour & "\" & Indice & "\" & Indice & "_Lettre.pdf") objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "MonSMTP" objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "MonEmail" objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "MonMotDePasse" objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60 objMail.Configuration.Fields.Update objMail.send rs1.MoveNext Loop End If Set fso = Nothing Set rs1 = Nothing End Function
Farid
Partager