Bonjour,
Peut-on envoyer un e-mail avec un script vbs ?
Si oui comment ?
Merci
Version imprimable
Bonjour,
Peut-on envoyer un e-mail avec un script vbs ?
Si oui comment ?
Merci
:roll:
Je pense que tu n'as pas fait de recherches préalables.
Rechercher dans ce forum avec le mot "mail", 120 réponses
Si mais je n'ai pas trouvé de post avec un script qui fonctionne :(.
Quelqu'un pourrait modifier la partie configuration de ce code avec un serveut smtp connu comme celui de google afin que ce script marche ? Je me m'y connais pas en configuration du CDO.
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 Dim config As CDO.Configuration Dim email As CDO.Message Set config = New CDO.Configuration With config.Fields .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = CDO.cdoSendUsingPort .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "le.smtp.google" .Update End With Set email = New CDO.Message With email Set .Configuration = config .From = "toto@a.com" .To = "tata@a.com" .Subject = "Sujet" .Textbody = "Blabla" .Send End With
Déjà tu devrais essayer ton script sur un serveur SMTP à toi avec de vraies adresses, parce que meme si ton script etait correct google ne te laisserait pas envoyer ce mail (sinon tout le monde enverrait du spam via google avec des scripts).
http://www.developpez.net/forums/d82...oir-mails-vbs/
Pour envoyer et recevoir.
Si tu es chez free, de chez toi tu peux utiliser smtp.free.fr et ça fonctionne :ccool:
Par contre chez gmail le serveur smtp est bloqué tu ne peux donc pas utiliser une adresse google pour faire ton test.
Courage
Bonjour
à tester avec le script précédent :
en ajoutant, modifiant ses informations : smtp.gmail.com utilisation SSL.
Citation:
.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 'numéro du port du serveur d'envoie du mail
.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = username ' remplacer
.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = password ' remplacer
:salut:
Voici un exemple qui envoie un simple HTML E-Mail Message avec pièce jointe via les serveurs de Gmail en utilisant l'authentification SMTP et SSL.
C'est comme tout autre courrier, mais exige que vous définissez le port SMTP à 465.
Donc c'est juste vous deviez modifier la partie de l'authentification càd votre Login et votre mot de passe Gmail.
Code:
1
2
3
4
5
6
7 'Your UserID on the SMTP server objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "YourLoginGmail@gmail.com" 'change this to yours 'Your password on the SMTP server objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "YourPasswordGmail" 'change this to yours
Code:
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68 'This sample sends a simple HTML EMail Message with Attachment File via GMail servers using SMTP authentication and SSL. 'It's like any other mail but requires that you set the SMTP Port to 465 and tell CDO to use SSL 'By Hackoo © 2011 On Error Resume Next Const cdoSendUsingPickup = 1 'Send message using the local SMTP service pickup directory. Const cdoSendUsingPort = 2 'Send the message using the network (SMTP over the network). Const cdoAnonymous = 0 'Do not authenticate Const cdoBasic = 1 'basic (clear-text) authentication Const cdoNTLM = 2 'NTLM sFilePath="C:\SSLGmail.rar" 'Path of the Attached File Set objMessage = CreateObject("CDO.Message") objMessage.Subject = "Example CDO Message" objMessage.From = """Me"" <Mymail@gmail.com>" 'change this to yours objMessage.To = "dest@yahoo.fr" 'change this To objMessage.CC = "dest2@yahoo.fr" 'change this CC means : Carbon Copy objMessage.BCC = "dest3@gmail.com" 'change this BCC means : Blink Carbon Copy sBody = "<center><font size=4 FACE=Tahoma Color=red>This is some sample message in HTML.<br> It was sent using SMTP authentication and SSL." objMessage.HTMLBody = sBody & _ "<center><font size=4 FACE=Tahoma Color=red>" & _ messageHTML & _ "<br><br><img src=http://photomaniak.com/upload/out.php/i1102064_IDNlogo.gif>" objMessage.AddAttachment sFilePath '==This section provides the configuration information for the remote SMTP server. objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Name or IP of Remote SMTP Server objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com" 'SMTP SERVER of GMAIL must be inchanged 'Type of authentication, NONE, Basic (Base64 encoded), NTLM objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic 'Your UserID on the SMTP server objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "YourLoginGmail@gmail.com" 'change this to yours 'Your password on the SMTP server objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "YourPasswordGmail" 'change this to yours 'Server port (typically 25 and 465 in SSL mode for Gmail) objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 'don't change this 'Use SSL for the connection (False or True) objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True 'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server) objMessage.Configuration.Fields.Item _ ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60 objMessage.Configuration.Fields.Update '==End remote SMTP server configuration section== objMessage.Send If Err.Number <>0 Then MsgBox Err.Description,16,"Erreur" msgbox "le mail n'a pas pu être envoyé !",16,"Information" Else msgbox "Le mail a été bien envoyé !",64,"Information" End If On Error GoTo 0
Bonjour
merci pour votre script
j'ai un soucis avec le corps du texte en HTML
sTable = "<html><body> ESSAI </body></html>"
objEmail.HTMLBody = sTable
ceci arrive dans ma messagerie comme une pièce jointe marque comme ci dessous
Inconnu <text/html> (972 R) Aperçu | Télécharger | Supprimer
si je clique sur Inconnu une page HTML s'ouvre
je voudrais avoir ESSAI dans le corps du texte comme pour objEmail.TextBody
merci pour votre aide :)
:salut: essayez ceci : [HTA] SMTP Mail Client avec pièce jointe
Bonjour,
Jette un oeil à ce code :P :
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 'FONCTION ENVOI MAIL Function SendMail(strTo, strBody, strTitre) Set objMail = CreateObject("CDO.Message") Set objConfig = CreateObject("CDO.configuration") Set objFields = objConfig.Fields With objFields .Item("http://schemas.microsoft.com/cdo/configuration/SendUsing")= 2 'Définit le type d'envoi en SMTP 'Serveur Mail Interne .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")= "IP_SMTP" .Item("http://schemas.microsoft.com/cdo/configuration/SMTPServerPort")= 25 .Update End With With objMail Set .Configuration = objConfig .To = strTo .Cc = strCc .Bcc = strBcc .AddAttachment("logo.jpg") .From = "test@test.com" .Subject = strTitre .HTMLBody = strBody .Send End With End Function