[FAQ] Envoi de mail en SMTP, CDO
Bonsoir, pour inaugurer ce nouveau sous-forum , j'aurai besoin de votre aide pour "tester" ce code adapter de la :faq: VB
Q : Comment envoyer un mail en utilisant CDO...(SMTP)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
Dim oCDO
Set oCDO = CreateObject("CDO.Message")
With oCdo
With .Configuration.Fields ' Configuration "du compte mail SMTP"
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.tele2.fr"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = "587"
'----- Dans le cas ou le serveur de mail (comme le mien) demande une authentification
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = "1"
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "eu20012007"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "MonMotdePasse"
'----------------
.Update
End With
.From = "bbil@gmail.com"
.to = "bbil@gmail.com"
.Subject ="Essai de mail" & Now
.TextBody ="Voici un petit message " & vbCrlf & "pour tester l'envoi de mail par CDO/VBScript"
.Send
End With |
commencer par adapter la première partie du code à votre configuration de mail ... dans mon cas .. tele2.. me réclame une authentification ...par login mot de passe et l'utilisation du port 587 habituellement le port c'est 25 si vous n'avez pas besoin d'authentification modifiez les lignes ...:
Code:
1 2 3 4 5 6 7 8 9 10 11
|
(...)
With oCdo
With .Configuration.Fields ' Configuration "du compte mail SMTP"
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.wanadoo.fr"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = "25"
.Update
End With
.From = "bbil@wanadoo.fr"
(...) |
:merci: d'avance pour vos commentaires...;)