VBA Excel - envoi mail par GMAIL

Fermé
Eaheru Messages postés 197 Date d'inscription mercredi 23 juin 2010 Statut Membre Dernière intervention 12 mars 2018 - Modifié le 11 mars 2018 à 12:25
Eaheru Messages postés 197 Date d'inscription mercredi 23 juin 2010 Statut Membre Dernière intervention 12 mars 2018 - 12 mars 2018 à 08:55
Bonjour,

Je tente d'utiliser le code ci dessous, la fonction d'envoi d'email est assurée mais le résultat est un double envoi du même email et donc mon interlocuteur reçoit 2 fois le même email.
Malgre mes efforts je n'arrive pas a regler ce souci. Auriez vous une idée ?

Merci d'avance pour votre aide.
Cordialement

Sub EnvoiMail_CDO()

Dim iMsg As Object, iConf As Object, Flds As Object
Set iMsg = CreateObject("cdo.message")
Set iConf = CreateObject("cdo.configuration")

Set Flds = iConf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'remplacez "smtp.nomserveur.fr" par le nom de serveur de votre FAI :
'http://outlook.developpez.com/faq/index.php?page=Configuration#Paras_FAI
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"

'Mais si votre serveur demande une authentification,
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = "1"
'.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = Identifiant & "@gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = Identifiant & "@gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = Mdp
'Si votre serveur demande une connexion sûre (SSL)
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = "true"
.Update
End With

With iMsg
Set .Configuration = iConf
.To = AdresseMailPersonne1
.Cc = ""
.From = Identifiant & "@gmail.com"
.Subject = "Plan : " & TypeSuivi & " - " & Prenom & " " & Nom
.HTMLBody = "<BODY><FONT face=arial color=#000000 size=2>" & _
"Bonjour " & Prenom & ",<br><br>Un " & TypeSuivi & " a été envoyé le " & DateEnvoi & " à <B>" & Prenom & " " & Nom & "</B>.<br><br>" & _
"Je vous remercie de m'adresser, par retour d'email au plus tard le <B><u>" & DatePA & "</B></u>, ce document." & vbCrLf & vbCrLf & _
"Dans l'attente,<br>" & _
"Cordialement,<br></FONT></BODY>"
'If form_email.piece_jointe <> "" Then .AddAttachment form_email.piece_jointe
.Send
End With

End Sub


A voir également:

1 réponse

Eaheru Messages postés 197 Date d'inscription mercredi 23 juin 2010 Statut Membre Dernière intervention 12 mars 2018 20
Modifié le 12 mars 2018 à 08:55
Quelqu'un aurait une idée ? :)
0