IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VBScript Discussion :

Script VBS email


Sujet :

VBScript

  1. #1
    Invité
    Invité(e)
    Par défaut Script VBS email
    Bonjour je suis débutant en programmation et j'aimerais avoir un script qui envoie un email a son lancement, j'ai trouver celui ci mais il affiche un message d'erreur "La valeur de configuration "SenUsing" est non (ligne : 46, caract : 2)". pouvez-vous m'aider a corriger l'erreur ? merci

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    Option Explicit
    Dim objMessage, Email, EPass
     
    Email = "*****@gmail.com"
    EPass = "******"
     
     
    Set objMessage = CreateObject("CDO.Message")
    objMessage.Subject = "hi"
     objMessage.From = Email
    objMessage.To = "******@gmail.com"
     objMessage.TextBody = "message body here"
    'objMessage.AddAttachment ""
     
     objMessage.Configuration.Fields.Item _
     ("http://schemas.microsoft.com/cdo/conf...") = 2
     
     'Name or IP of Remote SMTP Server
     objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/conf...") = "smtp.gmail.com"
     
     objMessage.Configuration.Fields.Item _
     ("http://schemas.microsoft.com/cdo/conf...") = 1
     
     'Your UserID on the SMTP server
     objMessage.Configuration.Fields.Item _
     ("http://schemas.microsoft.com/cdo/conf...") = Email
     
     'Your password on the SMTP server
     objMessage.Configuration.Fields.Item _
     ("http://schemas.microsoft.com/cdo/conf...") = EPass
     
     'Server port (typically 25)
     objMessage.Configuration.Fields.Item _
     ("http://schemas.microsoft.com/cdo/conf...") = "465"
     
     'Use SSL for the connection (False or True)
     objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/conf...") = False
     
     '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/conf...") = 60
     
     objMessage.Configuration.Fields.Update
     objMessage.Send
     
    MsgBox "Message sent"

  2. #2
    Expert éminent
    Avatar de hackoofr
    Homme Profil pro
    Enseignant
    Inscrit en
    Juin 2009
    Messages
    3 836
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Juin 2009
    Messages : 3 836
    Points : 9 217
    Points
    9 217
    Par défaut

    Tout d'abord il faut bien vérifier les paramèters de sécurité de votre gmail ici : Il faut que le paramètre "Autoriser les applications moins sécurisées" soit activé
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    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
    '===========================================================
    EmailSender = "VotreLogin@gmail.com" 'à changer
    PassGmail = "VotrePassGmail" 'à changer
    Email_Destinataire = "TOTO@yahoo.fr" 'à changer
    '===========================================================
    Set objMessage = CreateObject("CDO.Message")
    objMessage.Subject = "Example CDO Message"
    objMessage.From = """Me"" <"& EmailSender &">"
    objMessage.To = Email_Destinataire 
    objMessage.HTMLBody = "<H1>Ceci est exemple d'envoi mail ...</H1><br><h2>It was sent using SMTP authentication and SSL.</h2>"
     
    '==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"
     
    '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") = EmailSender
     
    'Your password on the SMTP server
    objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = PassGmail 
     
    'Server port (typically 25)
    objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
     
    '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==
    On Error Resume Next
    objMessage.Send
    If err <> o Then
    Msgbox Err.Description,vbCritical,Err.Description
    else
    MsgBox "Message envoyé avec succés !",VbInformation,"Message envoyé avec succés !"
    end if

  3. #3
    Invité
    Invité(e)
    Par défaut
    MERCI

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Débutant] Forcer envoie email - script vbs
    Par yoyohand dans le forum EDI/Outils
    Réponses: 0
    Dernier message: 13/01/2015, 18h52
  2. Script VBS - Focus garder la fenêtre en premier plan
    Par Furius dans le forum VBScript
    Réponses: 4
    Dernier message: 13/12/2005, 00h27
  3. Réponses: 2
    Dernier message: 19/07/2005, 15h14
  4. Probleme recuperation d'une valeur : script vbs -> .bat
    Par pinpin_du_net dans le forum Windows
    Réponses: 3
    Dernier message: 10/05/2005, 13h43
  5. Imprimer un fichier texte avec un script vbs
    Par Persons dans le forum Windows
    Réponses: 3
    Dernier message: 23/12/2004, 17h47

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo