Private Sub envoiCdo()
On Error GoTo Error_send
Dim oCdo As Object
Set oCdo = CreateObject("CDO.Message")
With oCdo
With .Configuration.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'ou CdoSendUsingPort : utilisation réseau
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com" 'nom ou IP du serveur SMTP
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 'port utilisé
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "xxxxxxxxxx@gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "zzzzzzzz"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
.Update
End With
.Subject = "envoi exemple" ' objet du message
.From = "xxxxxxxxx@gmail.com" ' adresse de l'expéditeur
.To = "sssssssss@ccccccccc" ' adresse du destinataire
.TextBody = "Ceci est un message de test." ' corps du message en format texte brut
.Send
End With
Fin:
Set oCdo = Nothing
Exit Sub
Error_send:
MsgBox "Erreur d'envoi " & Err.Number & " " & Err.Description
Resume Fin
End Sub