0/5 (15 avis)
Vue 6 733 fois - Téléchargée 518 fois
<html> <head> <HTA:APPLICATION ICON="icon.ico" APPLICATIONNAME = "SMTP Mail Client" BORDER="dialog" BORDERSTYLE="complex" CONTEXTMENU="no" SYSMENU="yes" MAXIMIZEBUTTON="no" SCROLL="no"> <title>SMTP Mail Client © Hackoo</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style> body{ background-color: lightblue; } label,.btn{ font-weight: bold; } </style> <script language="VBScript"> Const cdoSendUsingPickup = 1 Const cdoSendUsingPort = 2 'Must use this to use Delivery Notification Const cdoAnonymous = 0 Const cdoBasic = 1 ' clear text Const cdoNTLM = 2 'NTLM 'Delivery Status Notifications Const cdoDSNDefault = 0 'None Const cdoDSNNever = 1 'None Const cdoDSNFailure = 2 'Failure Const cdoDSNSuccess = 4 'Success Const cdoDSNDelay = 8 'Delay Const cdoDSNSuccessFailOrDelay = 14 'Success, failure or delay messageSSLHTML = "<center><font size=4 FACE=Comic sans MS style=font-weight:bold Color=red Color=red>Ceci est un exemple de message en HTML.<br>Il a été envoyé en utilisant l'authentification SMTP et SSL.<br><br>" Signature = "<center><font size=10 FACE=Comic sans MS style=font-weight:bold Color=red><br>©<br><img src=http://photomaniak.com/upload/out.php/i1102064_IDNlogo.gif>" Sub ViaGmail Dim f1 f1 = file.Value Login = InputBox ("Donner Votre adresse email !", "ADRESSE GMAIL DU EXPEDITEUR", "moi@gmail.com") Password = InputBox ("Donner Votre Mot de passe email !", "VOTRE MOT DE PASSE GMAIL", "") GmailBox=MsgBox ("Envoi avec ces Options:" & vbCrLf &"Expéditeur :"& Login & vbCrLf & "Destinataire : "& txtTo.Value & vbCrLf & "Sujet :" & txtSubject.Value & vbCrLf & "FileAttach1 :"& f1 ,vbYesNo+64,"Message Options") If GmailBox = vbYes Then if SendGmailSSL(Login,Password, txtTo.Value, txtSubject.Value, txtBody.value+messageSSLHTML+Signature,f1)= 0 Then MsgBox "Le Mail a été envoyé avec succès !",vbInformation ,"Information" Else MsgBox "Echec d'envoi du Mail !",vbExclamation ,"Information" End If End If End Sub Function SendGmailSSL( sFrom, sPassword, sTO ,sSubject, sBody, sFilePath1) Set objMessage = CreateObject("CDO.Message") objMessage.Subject = sSubject objMessage.From = sFrom objMessage.To = sTO objMessage.HTMLBody = sBody If sFilePath1 <> "" Then objMessage.AddAttachment sFilePath1 End If objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com" objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = sFrom objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = sPassword objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True objMessage.Configuration.Fields.Update On Error Resume Next objMessage.Send SendGmailSSL = Err.Number If Err.Number <> 0 Then MsgBox Err.Description, 16, "SendGmailSSL Erreur" End If End Function Sub window_onload() CenterWindow 415, 600 End Sub Sub CenterWindow(x,y) window.resizeTo x, y iLeft = window.screen.availWidth/2 - x/2 itop = window.screen.availHeight/2 - y/2 window.moveTo ileft, itop End Sub Sub SendMail() SendMailMessage txtFrom.Value, txtTo.Value, txtSubject.Value, txtBody.value ,txtSMTPSERVER.Value, file.Value End Sub Sub SendMailMessage( sFrom, sTo, sSubject, sBody, SMTPSERVER, File) MsgBox "Envoi du Mail avec ces options:"& vbCrLf &"Expéditeur: "& sFrom & vbCrLf & "To: " & sTo & vbCrLf &"Sujet: " & sSubject & vbCrLf &"Text Message: " & sBody & vbCrLf & "SMTP SERVER: " & SMTPSERVER & vbCrLf & "Piéce-jointe: " & File,64,"Send Email" messageHTML="<center><font size=4 FACE=Comic sans MS style=font-weight:bold Color=red>Ceci est un exemple de message avec Signature en HTML <br> envoyé par Hackoo !" File = document.getElementById("file").Value Set msg = CreateObject("CDO.Message") With msg .From = sFrom .To = sTo .Subject = sSubject .TextBody = sBody .HTMLBody=sBody & messageHTML & Signature .Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 .Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTPSERVER .Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 If File <> "" Then .AddAttachment File 'Ajout de la piéce-jointe End If .Configuration.Fields.Update On Error Resume Next .Send If Err.Number <>0 Then MsgBox Err.Description,16,"Error Sending Mail" Else MsgBox "Le Mail a été envoyé avec succès !",64,"Information" End If End With End Sub </script> </head> <body> <label for="Expéditeur" style="width: 120; textalign: right;">Expéditeur:</label><input type="text" id="txtFrom" name="Expéditeur" value="Expéditeur@gmail.com"><br /> <label for="to" style="width: 120; textalign: right;">Destinataire:</label><input type="text" id="txtTo" name="to" value="Destinataire@gmail.com"><br /> <label for="subject" style="width: 120; textalign: right;">Sujet:</label><input type="text" id="txtSubject" name="sujet" value="Sujet"><br /> <label for="txtSMTPSERVER" style="width: 120; textalign: right;">SMTP:</label><input type="text" id="txtSMTPSERVER" name="txtSMTPSERVER" value="smtp.serveur.com"><br /> <label for="file">Pièce-Jointe :</label><br /> <input type="file" name="file" id="file" /><br> <label>Message:</label><br /> <textarea id="txtBody" rows="20" cols="45"></textarea><br><br> <center> <input class="btn" type="button" value="Envoyer Via Gmail" onClick="ViaGmail"> <input class="btn" type="button" value="Envoyer Via SMTP" onClick="SendMail"> </body> </html>
Je compte l'utiliser dans un logiciel à moi, qui une fois qu'il aura généré ça sauvegarde l'enverra automatiquement par mail avec ton script VBS.
Je code en VB6 ce mini soft (question de licence sinon sa serait VB.NET), j'aurais besoin :
- de pouvoir executer ton script depuis VB6 et je ne sais pas comment faire de façon transparente
- d'envoyer la pièce jointe en suite
Pour le moment la ligne 8 et la ligne 20 bug, la 8 me dit :
Type incompatible: 'piece'
erreur d'exécution VBS.
si je commente la ligne de la PJ, bug à la ligne 20, logique en même temps.
Serais-tu m'expliquer pourquoi ?
je viens de tester le de hackoo. pas de souci. il marche très bien. par contre, je voulais savoir si l'on pouvait modifier pour qu'il soit exécuté automatiquement et récuperer la pièce jointe et l'envoyer. je voulais mettre ce code en tache planifié.
merci de votre aide.
http://www.vbfrance.com/codes/EDITEUR-BBCODE-ENVOI-MAIL-ANIME-AGENT-MERLIN-MAGICIEN_53304.aspx
comment ajouter un champ BCC et l'envoi sous HTML
et merci
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.