Téléchargé 8 fois
Vote des utilisateurs
1
0
Détails
Licence : Freeware
Mise en ligne le 14 mars 2011
Plate-forme :
Windows
Langue : Français
Référencé dans
Navigation
[HTA] SMTP Mail Client avec pièce jointe
[HTA] SMTP Mail Client avec pièce jointe
Voici un exemple de formulaire en HTA HTML Application pour envoyer un e-mail avec une pièce-jointe par deux méthodes:
1-Méthode: Via le serveur Gmail en utilisant l'authentification SMTP et SSL de ce dernier
2-Méthode: Via Votre Serveur SMTP sans authentification
Dans cet exemple vous pouvez utiliser du code HTML dans votre message. Par exemple moi j'ai utilisé une image comme signature a la fin du mail !
NB: Pour la 2ème méthode on peut l'utiliser sans login et sans mot de passe si on est sous le même Domaine et on peut aussi l'utiliser aussi si on est devant un Proxy , il suffit juste remplacer le contenu du champ SMTP "smtp.serveur.com"par son adresse IP par exemple si votre Proxy a comme adresse IP 172.16.0.1 ou bien 192.168.1.1
( A vérifier chez vous )
1-Méthode: Via le serveur Gmail en utilisant l'authentification SMTP et SSL de ce dernier
2-Méthode: Via Votre Serveur SMTP sans authentification
Dans cet exemple vous pouvez utiliser du code HTML dans votre message. Par exemple moi j'ai utilisé une image comme signature a la fin du mail !
NB: Pour la 2ème méthode on peut l'utiliser sans login et sans mot de passe si on est sous le même Domaine et on peut aussi l'utiliser aussi si on est devant un Proxy , il suffit juste remplacer le contenu du champ SMTP "smtp.serveur.com"par son adresse IP par exemple si votre Proxy a comme adresse IP 172.16.0.1 ou bien 192.168.1.1
( A vérifier chez vous )
c'est une petite mise à jour pour Formater le textaera au format html pour contourner le problème du message qui s'affiche sur une seule ligne
Un Grand
à patricktoulon pour cette Astuce 
| Code : | Sélectionner tout |
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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | <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
'Formater le textaera au format html pour contourner le problème du message qui s'affiche sur une seule ligne
'Un Grand Merci à patrick pour cette Astuce
Dim st,i,tb,f1,paragraphe
st=txtbody.value
tb = split(st,vbcrlf)
For i = lbound(tb) to ubound(tb)
paragraphe=paragraphe & tb(i) & "<br>" & vbcrlf
Next
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, paragraphe+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()
'Formater le textaera au format html
Dim st,i,tb,paragraphe
st=txtbody.value
tb = split(st,vbcrlf)
For i = lbound(tb) to ubound(tb)
paragraphe=paragraphe & tb(i) & "<br>" & vbcrlf
Next
SendMailMessage txtFrom.Value, txtTo.Value, txtSubject.Value, paragraphe ,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.orange.fr"><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> |
bonjour hackoofr
jai trouver ton code bien pratique
il y avais un petit detail cependant qui me genait
le texte du texaera sur plusieures lignes se retrouvait sur une seule ligne dans le message
il a falu formater le texte au format html
je l'ai un peu remanier a ma sauce
j'ai remplacer le textbox expediteur par une combobox pour avoir mon email pro et privé
j'ai supprimer aussi la fonction gmail inutile pour moi
pour le text j'ai utilisé une boucle avec la fonction split par les saut de ligne
enfin voila ce que ca donne
qu'en pense tu ?
au plaisir
jai trouver ton code bien pratique
il y avais un petit detail cependant qui me genait
le texte du texaera sur plusieures lignes se retrouvait sur une seule ligne dans le message
il a falu formater le texte au format html
je l'ai un peu remanier a ma sauce
j'ai remplacer le textbox expediteur par une combobox pour avoir mon email pro et privé
j'ai supprimer aussi la fonction gmail inutile pour moi
pour le text j'ai utilisé une boucle avec la fonction split par les saut de ligne
enfin voila ce que ca donne
| Code : | Sélectionner tout |
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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
<html>
<head>
<HTA:APPLICATION
ICON="icon.ico"
APPLICATIONNAME = "ENVOYER UN MAIL"
BORDER="dialog"
BORDERSTYLE="complex"
CONTEXTMENU="yes"
SYSMENU="yes"
MAXIMIZEBUTTON="yes"
SCROLL="no"
CAPTION="no"
>
<title>MAILERS</title>
<style>
body
{
color:black;
background-color:white;
background-image:url(fond.jpg);
background-repeat:no-repeat;
}
label,.btn{
font-weight: bold;
}
</style>
<script language="VBScript">
Sub window_onload()
CenterWindow 900, 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()
if txtTo.value="" then
msgbox "entrez d'abors un destinataire"
exit sub
end if
lien="<A href=mailto:toto@msn.com>toto@msn.com</A>"
' on va transformer le textaera au format html (chaque ligne entre balises)
Dim st,i,tb,files
dim paragraphe
st=txtbody.value
tb = split(st,vbcrlf)
For i = lbound(tb) to ubound(tb)
paragraphe=paragraphe & tb(i) & "<br>" & vbcrlf
next
paragraphe=paragraphe & "<br><br>"& _
"<center><font size=4 FACE=Comic sans MS style=font-weight:bold Color=violet>POUR TOUT RESEIGNEMENT<br>OU TOUTES QUESTION CLIQUER SUR LE LIEN POUR ME CONTACTER<br><br>" & lien
Files = file.Value
msgbox file.Value & vbcrlf & txtTo.value
Set msg = CreateObject("CDO.Message")
With msg
.From = lstChaines.value
.To = txtTo.value
.Subject = txtSubject
.HTMLBody=paragraphe
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = txtSMTPSERVER.Value'SMTPSERVER
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
If File.value <> "" Then
.AddAttachment File.value '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
if file.value="" then piece=""
if file.value<>"" then piece = "avecle fichier " & vbcrlf & file.value & vbcrlf & "en piece jointe"
MsgBox "Le Mail a été envoyé avec succès !"& vbcrlf & " à" & vbcrlf & txtTo.value & vbcrlf & piece,64,"Information"
End If
End With
End Sub
sub fermeture()
window.close
end sub
</script>
</head>
<body>
<font color="#FFFF33">
<label for="Expéditeur" style="width: 120 color=#FFFF00; textalign: right;">Expéditeur:</label><SELECT NAME="lstChaines" SIZE=1>
<OPTION VALUE="toto@msn.com">toto@msn.com
<OPTION VALUE="titi@msn.com">titi@msn.com
</SELECT>
<br />
<label for="to" style="width: 120; textalign: right;">Destinataire:</label><input type="text" id="txtTo" name="to" value=""><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.aliceadsl.fr"><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="80"></textarea><br><br>
<center>
<input class="btn" type="button" value="ENVOYER" onClick="SendMail">
<input class="btn" type="button" value="fermer"; onClick="fermeture">
</body>
</html> |
qu'en pense tu ?
au plaisir
bonjour
ya pas de quoi
voila un bon petit formulaire qui passe partout
au plaisir
ya pas de quoi
voila un bon petit formulaire qui passe partout
au plaisir
y a un probleme pour moi il me dit que le mail a ete envoyer mais je ne le recois pas


Developpez.com décline toute responsabilité quant à l'utilisation des différents éléments téléchargés.
