TUTOS.EU

Envoyer un mail en VbScript

Comment envoyer un mail en Vbscript

Option Explicit

Dim varSMTPRelay 'Adresse du serveur de messagerie / relais smtp 
Dim varDestEmail, varSujetMail, varMessageMail, varSenderMail

varSMTPRelay = "AdresseServeurSMTP"
varDestEmail = "AdressemailDestinataire@domaine.com"
varSenderMail = "AdressemailEnvoyeur@domaine.com"

varSujetMail = "Password Will Expire"
varMessageMail = "Votre mot de passe va expirer dans " & "x" & " jours."

Call EnvoyerEmail(varSMTPRelay, varDestEmail, varSenderMail, varSujetMail, varMessageMail)

Public Function EnvoyerEmail(varSMTPRelay, varDestEmail, varSenderMail, varSujetMail, varMessageMail)

	Dim objMessage

	Set objMessage = CreateObject("CDO.Message")
	objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
	objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = varSMTPRelay
	objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
	objMessage.Configuration.Fields.Update

	objMessage.Subject = varSujetMail
	objMessage.Sender = varSenderMail
	objMessage.To = varDestEmail
	objMessage.TextBody = varMessageMail
	objMessage.Send

	Set objMessage = Nothing

End Function
Lien vers le fichier : cliquez ici Copier le code

2