Bonjour à tous

Afin de ne pas passer par outlook, j'utilise CDO pour envoyer un mail.

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
67
68
69
 
 
Dim iMsg As New CDO.Message
Dim iConf As New CDO.Configuration
Dim Flds 
Dim strUser As String
Dim strPassword As String
Dim strSubject as string
Dim strExpediteur as string
Dim strDestinataire as string
Dim strTexte as string
Dim strPiece as string
 
 
Set Flds = iConf.Fields
 
Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory.
Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network).
 
Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM
 
Set objMessage = CreateObject("CDO.Message")
 
 
objMessage.Subject = strSubject
objMessage.From = strExpediteur
objMessage.To = strDestinataire
objMessage.TextBody = strTexte
objMessage.AddAttachment = strPiece
'==This section provides the configuration information for the remote SMTP server.
 
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
 
'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "server.fr"
 
'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
 
'Your UserID on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = strUser
 
'Your password on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = strPassword
 
'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
 
'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
 
'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 5
 
objMessage.Configuration.Fields.Update
 
'==End remote SMTP server configuration section==
 
objMessage.Send
J'aimerai juste avant de l'envoyer pour faire un aperçu un peu à la façon qui passe par outlook avec la fonction true.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
 
DoCmd.SendObject acSendReport, stDocName, acFormatPDF, myEmail, "", "", MySubject, myLettre, True
J'ai dans l'idée de faire un formulaire qui rappelle celui du mail avec les champ remplis par les différents renseignements.
Avez-vous d'autres suggestions ?
Par avance merci.