Envoyer un mail avec vbscript (du déja vu sur ce site)

Description

Petit programme permettant d'envoyer des mails avec pièce jointe!
Avant de publier ce code source j'ai fouillé dans le site et j'ai trouvé
des sources à peu prés similaire à la mienne! Donc ne vous émerveillez pas
ça n'est pas du nouveau! Le seul truc qui est peut être différent c'est l'interface
graphique! extension .hta ou .html
Il y a peu être des bugs pour vous mais pour moi il n'y en a aucun!

Source / Exemple :


<head><title>_______________________MAIL___________________</title>
<script language=vbscript>

sub window_onload()
l.style.left=0
l.style.top=0
self.resizeto 463,437
self.moveby 10, 10

end sub

sub envoi()
if document.l.expediteur.value<>"" and document.l.destinataire.value<>"" then
expe=document.l.expediteur.value
desti=document.l.destinataire.value

set r=createobject("CDO.Message")
r.from=expe
r.to=desti
r.subject= document.l.objet.value
r.TextBody= document.l.n.value
r.Configuration.fields.item("http://schemas.microsoft.com/cdo/configuration/sendusing")= 2
'_____________________________INDEX SERVER SMTP_________________________ 
voila=instr(desti,"voila.fr")
hotmail=instr(desti,"hotmail")
msn=instr(desti,"msn.com")
yahoo=instr(desti,"yahoo")
wanadoo=instr(desti,"wanadoo")
caramail=instr(desti,"caramail")
laposte=instr(desti,"laposte.net")
'________________________VOILA_____________________
if voila>=1 then
r.Configuration.fields.item("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.voila.fr"
end if
 
'_____________________________HOTMAIL________________
if hotmail>=1 then
r.Configuration.fields.item("http://schemas.microsoft.com/cdo/configuration/smtpserver")="mx4.hotmail.com"
end if

'___________________________YAHOO________________________
if yahoo>=1 then
r.Configuration.fields.item("http://schemas.microsoft.com/cdo/configuration/smtpserver")="mx4.mail.yahoo.com"
end if

'___________________________WANADOO________________________
if wanadoo>=1 then
r.Configuration.fields.item("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.wanadoo.fr"
end if
'___________________________CARAMAIL________________________
if caramail>=1 then
r.Configuration.fields.item("http://schemas.microsoft.com/cdo/configuration/smtpserver")="mx2.mail.spray.net"
end if
'__________________________LAPOSTE________________________
if laposte>=1 then
r.Configuration.fields.item("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp1.laposte.net"
end if
r.configuration.fields.update
if document.l.fich.value<>"" then
r.addattachment document.l.fich.value
end if

r.send
document.l.n.value=""
document.l.destinataire.value=""

document.l.fich.value=""

msgbox"Message envoyé avec succés!!!",vbsystemmodal,"OK"
else
msgbox"Renplissez correctement les champs destinataire et expediteur!",vbsystemmodal+vbinformation,"ATTENTION"
 

end if

end sub

sub window_onresize()
self.resizeto 463,437
self.moveby 10, 10

end sub

</script>

<BODY style="Font-Weight='bold'" BGColor="gray" LeftMargin=0 TopMargin=0 MarginWidth=0 MarginHeight=0 scroll=no >
<form name="l" style="position:absolute">
<table border=10>
<tr><td><p style="font-family:impact">Expéditeur:</p></td><td><input type="texte" size=50 id="expediteur" style="font-family:arial"></td></tr>

<tr><td><p style="font-family:impact">Destinataire:</p></td><td><input type="texte" size=50 id="destinataire" style="font-family:arial"></td></tr>

<tr><td><p style="font-family:impact">Objet:</p></td><td><input type="texte" size=50 id="objet" style="font-family:arial"></td></tr>
<tr><td colspan=2>
<p align=center>
<textarea id="n" rows=10 cols=60 style="font-family:arial"></textarea></p></td></tr><tr><td colspan=2></td></tr><tr>
<td colspan=2><input type=reset value="RESET" style="background:gray; cursor: ;font-size:6pt; font-family:comic sans ms"><p align=right><b>FICHIER JOINT:</b><input type="file" value="joindre" id="fich" style="font-family:arial" ></p>
</td></tr><tr><td colspan=2>
<p align=center>
<input type=button value=":::::ENVOYER:::::" style="background:gray; cursor:hand; font-family:scriptS; border:black 8px solid" onclick="envoi()"></p></td></tr>
</table>
</form>

</body>

Conclusion :


Ben vous copiez tout ça dans le bloc note et vous l'enregistrez avec l'extention .hta
Et si vous avez un problème avec les fichiers hta téléchargez le zip!
J'espère que ça fonctionne chez vous!
Il y aura des mises à jour! (plusieurs pièces jointes)!

Codes Sources

A voir également

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.