|
Envoyer un email en vba sans popup de sécurité |
|
|
|
|
Sujet longuement recherché sur google ....
Comment envoyer un email en vba sans popup de sécurité. L'astuce est de ne pas utiliser outlook pour envoyé l'email mais un serveur smtp précis.
Dans la fonction vous verrez aussi comment rendre le mail au format html et ajouter une pièce jointe.
Public Sub envoie_mail(depuis, destinataire, sujet, Body, fichier)
Dim Objemail Dim iconf
Set Objemail = CreateObject("CDO.Message") Set iconf = Objemail.Configuration
With iconf.Fields .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.free.fr" .Update End With Objemail.From = depuis Objemail.To = destinataire Objemail.Subject = sujet If Body "" Then Objemail.HTMLBody = Body End If If fichier "" Then Objemail.AddAttachment fichier End If Objemail.Send End Sub
|