Bonjour à tous,

J'ai un problème pour envoyer des messages avec CDO en utilisant mon compte GMail. J'utilise le code suivant :

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
Sub CDO2()
Dim Adresse As String, MDP As String, Desti As String
Adresse = "xxx@gmail.com" '*** mon adresse mail - à modifier
MDP = "xxx" '*** mon mot de passe GMail - à modifier
Desti = "xxx@xxx.com" '*** adresse du destinataire - à modifier
Set cdomsg = CreateObject("CDO.message")
With cdomsg.Configuration.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'NTLM method
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smptserverport") = 587
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = Adresse
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = MDP
.Update
End With
' build email parts
With cdomsg
.To = Desti
.From = "mygmail@gmail.com"
.Subject = "the email subject"
.TextBody = "the full message body goes here. you may want to create a variable to hold the text"
.Send
End With
    Set cdomsg = Nothing
End Sub

qui me donne l'erreur :
Erreur d'exécution '-2147220973 (80040213)':
Le transport a échoué dans sa connexion au serveur.

L'erreur semble liée à une spécificité GMail (j'arrive à envoyer un message via CDO et Free.

Merci d'avance.