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

Macros et VBA Excel Discussion :

Erreur Send Using non valide


Sujet :

Macros et VBA Excel

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre régulier
    Homme Profil pro
    Étudiant
    Inscrit en
    Mai 2016
    Messages
    11
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mai 2016
    Messages : 11
    Par défaut Erreur Send Using non valide
    Bonjour,

    J'essaye de faire fonctionner un code mais en vain. Alors quand je suis sur xp, au départ j'avais un problème --> "la valeur de configuration ‘SendUsing’ est non valide".

    Il m'a juste fallu définir Outlook express comme messagerie par défaut et de paramétrer le client Outlook Express en IMAP.

    Or sur certains postes tournant sur Windows 8 et 10, impossible de faire cette démarche. Existe-il un moyen de faire fonctionner le code autrement ?

    Ci-dessous le code:

    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
    Sub Bouton1139_Cliquer()
    Dim CdoMessage As CDO.Message
    Dim fichier As String
    Dim Dest As String
    Dim i As Integer
     
    Dim Copie As String
    Dim Exp As String 
     
     Set CdoMessage = CreateObject("CDO.Message")
     Set iConf = CreateObject("CDO.Configuration")
     Set Flds = iConf.Fields
     
     
     For i = 7 To 3006
     
     
     If Sheets("Avenant - Convention").Range("S" & i).Value = "créé" And Sheets("Avenant - Convention").Range("B" & i).Value = Sheets("Avenant - Convention").Range("G3").Value Then
     
     Set CdoMessage = New CDO.Message
     
     Copie = Sheets("Avenant - Convention").Range("ED" & i).Value
     Exp = Sheets("Avenant - Convention").Range("EB" & i).Value
     Dest = Sheets("Avenant - Convention").Range("EC" & i).Value
     LeRep = "P:\M200\R200\Suivi ressources 2016\Relance\176\"
     fichier = LeRep & Sheets("Avenant - Convention").Range("A" & i).Value & ".pdf"
     
     
     If Dir(fichier) = "" Then MsgBox "fichier " & fichier & " non trouvé": Stop
     
     With CdoMessage
     .Subject = "Signature Convention-Avenant 2016"
     .From = Exp
     .To = Dest
     .CC = Copie
     .BCC = ""
     .TextBody = "Bonjour," & _
     vbLf & "" & _
     vbLf & "Veuillez trouver en pièce jointe le contrat pour l'opération convenue entre nos deux sociétés." & _
     vbLf & "Merci de nous le retourner par envoi postal signé et tamponné, en 3 exemplaires originaux." & vbLf & vbLf & _
     "Vous en souhaitant bonne réception" & vbLf & vbLf & _
     "Cordialement" & vbLf & vbLf & _
     vbLf & Sheets("Avenant - Convention").Range("DZ" & i).Value
     
     .AddAttachment fichier
     .Send
     
     End With
     
     Set CdoMessage = Nothing
     Application.ScreenUpdating = True
     
    Sheets("Avenant - Convention").Range("S" & i).Value = "Envoyé"
     
    End If
    Next i
    End Sub
    Merci,

    Pascal

  2. #2
    Membre chevronné
    Profil pro
    Inscrit en
    Novembre 2007
    Messages
    473
    Détails du profil
    Informations personnelles :
    Localisation : France, Vendée (Pays de la Loire)

    Informations forums :
    Inscription : Novembre 2007
    Messages : 473
    Par défaut
    Bonjour,

    Tout d'abord merci de placer ton code entre #!

    Sans être certain essaye ainsi, je ne l'ai pas testé :

    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
    60
    61
    62
    63
    64
    65
    Sub Bouton1139_Cliquer()
    Dim CdoMessage As Object
    Dim Fichier As Variant
    Dim iMsga As Object, iConfa As Object, Fldsa As Object
    Dim Dest As String
    Dim i As Integer
     
    Dim Copie As String
    Dim Exp As String
     
     
     
    For i = 7 To 3006
     
     
    If Sheets("Avenant - Convention").Range("S" & i).Value = "créé" And Sheets("Avenant - Convention").Range("B" & i).Value = Sheets("Avenant - Convention").Range("G3").Value Then
     
    Set iMsga = CreateObject("cdo.message")
    Set iConfa = CreateObject("cdo.configuration")
     
    Set Fldsa = iConfa.Fields
    With Fldsa
        .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
        'remplacez "smtp.nomserveur.fr" par le nom de serveur de votre FAI :
        'http://outlook.developpez.com/faq/index.php?page=Configuration#Paras_FAI
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.orange.fr" 'A ADAPTER SELON LE FAI
        .Update
    End With
     
    Copie = Sheets("Avenant - Convention").Range("ED" & i).Value
    Exp = Sheets("Avenant - Convention").Range("EB" & i).Value
    Dest = Sheets("Avenant - Convention").Range("EC" & i).Value
    LeRep = "P:\M200\R200\Suivi ressources 2016\Relance\176\"
    Fichier = LeRep & Sheets("Avenant - Convention").Range("A" & i).Value & ".pdf"
     
     
    If Dir(Fichier) = "" Then MsgBox "fichier " & Fichier & " non trouvé": Stop
     
    With iMsga
    .Subject = "Signature Convention-Avenant 2016"
    .From = Exp
    .To = Dest
    .CC = Copie
    .BCC = ""
    .HTMLBody = TxtHtml("Bonjour," & _
    vbLf & "" & _
    vbLf & "Veuillez trouver en pièce jointe le contrat pour l'opération convenue entre nos deux sociétés." & _
    vbLf & "Merci de nous le retourner par envoi postal signé et tamponné, en 3 exemplaires originaux." & vbLf & vbLf & _
    "Vous en souhaitant bonne réception" & vbLf & vbLf & _
    "Cordialement" & vbLf & vbLf & _
    vbLf & Sheets("Avenant - Convention").Range("DZ" & i).Value)
     
    .AddAttachment Fichier
    .Send
     
    End With
     
    Set CdoMessage = Nothing
    Application.ScreenUpdating = True
     
    Sheets("Avenant - Convention").Range("S" & i).Value = "Envoyé"
     
    End If
    Next i
    End Sub
    Surtout adapte le FAI en regardant ici : http://outlook.developpez.com/faq/in...tion#Paras_FAI

  3. #3
    Membre régulier
    Homme Profil pro
    Étudiant
    Inscrit en
    Mai 2016
    Messages
    11
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mai 2016
    Messages : 11
    Par défaut
    Merci !!!!

    Alors ça ne marche pas, ça dit "sub ou fonction non définie" et ça bleute la zone "TxtHtml".

    Autre point. Dans l'entreprise où je travaille nous utilisons easy mail, c'est une sorte de gmail je crois. Dois-je prendre les paramètres pour gmail ? Sachant que nos adresses sont en prenom.nom@entreprise.fr. Je ne connais pas notre FAI donc.


    Merci de ton aide encore,

    Pascal

  4. #4
    Membre chevronné
    Profil pro
    Inscrit en
    Novembre 2007
    Messages
    473
    Détails du profil
    Informations personnelles :
    Localisation : France, Vendée (Pays de la Loire)

    Informations forums :
    Inscription : Novembre 2007
    Messages : 473
    Par défaut
    Pour gmail je ne sais pas trop mais essaye comme ceci , ça ne coûte rien:

    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
    60
    61
    62
    63
    64
    65
    Sub Bouton1139_Cliquer()
    Dim CdoMessage As Object
    Dim Fichier As Variant
    Dim iMsga As Object, iConfa As Object, Fldsa As Object
    Dim Dest As String
    Dim i As Integer
     
    Dim Copie As String
    Dim Exp As String
     
     
     
    For i = 7 To 3006
     
     
    If Sheets("Avenant - Convention").Range("S" & i).Value = "créé" And Sheets("Avenant - Convention").Range("B" & i).Value = Sheets("Avenant - Convention").Range("G3").Value Then
     
    Set iMsga = CreateObject("cdo.message")
    Set iConfa = CreateObject("cdo.configuration")
     
    Set Fldsa = iConfa.Fields
    With Fldsa
        .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
        'remplacez "smtp.nomserveur.fr" par le nom de serveur de votre FAI :
        'http://outlook.developpez.com/faq/index.php?page=Configuration#Paras_FAI
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com" 'A ADAPTER SELON LE FAI
        .Update
    End With
     
    Copie = Sheets("Avenant - Convention").Range("ED" & i).Value
    Exp = Sheets("Avenant - Convention").Range("EB" & i).Value
    Dest = Sheets("Avenant - Convention").Range("EC" & i).Value
    LeRep = "P:\M200\R200\Suivi ressources 2016\Relance\176\"
    Fichier = LeRep & Sheets("Avenant - Convention").Range("A" & i).Value & ".pdf"
     
     
    If Dir(Fichier) = "" Then MsgBox "fichier " & Fichier & " non trouvé": Stop
     
    With iMsga
    .Subject = "Signature Convention-Avenant 2016"
    .From = Exp
    .To = Dest
    .CC = Copie
    .BCC = ""
    .HTMLBody = TxtHtml("Bonjour," & _
    vbLf & "" & _
    vbLf & "Veuillez trouver en pièce jointe le contrat pour l'opération convenue entre nos deux sociétés." & _
    vbLf & "Merci de nous le retourner par envoi postal signé et tamponné, en 3 exemplaires originaux." & vbLf & vbLf & _
    "Vous en souhaitant bonne réception" & vbLf & vbLf & _
    "Cordialement" & vbLf & vbLf & _
    vbLf & Sheets("Avenant - Convention").Range("DZ" & i).Value)
     
    .AddAttachment Fichier
    .Send
     
    End With
     
    Set CdoMessage = Nothing
    Application.ScreenUpdating = True
     
    Sheets("Avenant - Convention").Range("S" & i).Value = "Envoyé"
     
    End If
    Next i
    End Sub
    Pour le txtHTML place dans un module ( ceci est fait pour les caractère spéciaux !)

    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
    Function TxtHtml(T As String) As String
    Dim Txt
    Dim Htm
    Dim I As Long
    TxtHtml = T
    Txt = "Á$á$É$é$Í$í$Ó$ó$Ú$ú$Ý$ý$À$à$È$è$Ì$ì$Ò$ò$Ù$ù$Â$â$Ê$ê$Î$î$Ô$ô$Û$û$Ä$ä$Ë$ë$Ï$ï$Ö$ö$Ü$ü$Ÿ$ÿ$Ã$ã$Õ$õ$Ç$ç$ $" & vbCrLf
    Htm = "Á$á$É$é$Í$í$Ó$ó$Ú$ú$Ý$ý$À$à$È$è$Ì$ì"
    Htm = Htm & "$Ò$ò$Ù$ù$Â$â$Ê$ê$Î$î$Ô$ô$Û$û$Ä$ä$Ë$ë"
    Htm = Htm & "$&Ouml;$&ouml;$&Uuml;$&uuml;$&Yuml;$&yuml;$&Atilde;$&atilde;$&Itilde;$&itilde;$&Otilde;$&otilde;$&Ccedil;$&ccedil;$&nbsp;$<br>"
    Txt = Split(Txt, "$")
    Htm = Split(Htm, "$")
    For I = 0 To UBound(Txt)
    TxtHtml = Replace(TxtHtml, Txt(I), Htm(I), 1, compare:=vbBinaryCompare)
    Next
    End Function
    Pour gmail si ça ne fonctionne pas fait signe, et il y a des gens dans le forum qui sauront je pense.

  5. #5

  6. #6
    Membre chevronné
    Profil pro
    Inscrit en
    Novembre 2007
    Messages
    473
    Détails du profil
    Informations personnelles :
    Localisation : France, Vendée (Pays de la Loire)

    Informations forums :
    Inscription : Novembre 2007
    Messages : 473
    Par défaut
    Commence par essayer ce que je t'ais envoyé hier et

    si on se réfère au message de Rdurupt je pense que si tu remplace dans le code que je t'ais envoyé comme ceci:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    With Fldsa
        .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
        'remplacez "smtp.nomserveur.fr" par le nom de serveur de votre FAI :
        'http://outlook.developpez.com/faq/index.php?page=Configuration#Paras_FAI
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SmTp.Gmail.com ' ou si ça  ne marche pas smtp.googlegmail.com
         .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
         .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = "1"
         .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "xxxx@gmail.com"
         .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "TonMotDePasse"
    'Si votre serveur demande une connexion sûre (SSL)
        .Item("[http://schemas.microsoft.com/cdo/configuration/smtpusessl]") = "true"
        .Update
    End With
    Mais il faut que tu récupère le password de la société !

    Sinon tu as la version outlook de Rdurupt

Discussions similaires

  1. Erreur ordinale 0 non valide
    Par Albertus14 dans le forum Delphi
    Réponses: 2
    Dernier message: 22/11/2014, 15h59
  2. [XL-2007] erreur 380 .value non valide
    Par pilounet54 dans le forum Macros et VBA Excel
    Réponses: 2
    Dernier message: 27/03/2012, 08h05
  3. [XL-2007] Erreur "Dimension spécifiée non valide pour le type de graphique en cours"
    Par m@tix dans le forum Macros et VBA Excel
    Réponses: 4
    Dernier message: 26/08/2011, 14h42
  4. Réponses: 2
    Dernier message: 22/04/2011, 15h26
  5. Erreur Fichier Projet Non Valide
    Par HighTouch dans le forum Windows Presentation Foundation
    Réponses: 13
    Dernier message: 03/06/2008, 12h58

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