Bonjour,

Afin d'envoyer des mails, j'utilise le code suivant (venant d'un tuto)

J'obtiens le message suivant "la valeur de configuration de send using est non valide" Ce bug correspond à la ligne indiquee d'une fleche (3ème ligne avant la fin du code)

merci pour votre aide....

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
Private Sub cmdEnvoyer_Click()
'txtForm
    CDOSendMail "toto@free.fr", "truc@free.fr", "titre", "message", "c:\test.txt"
    'txtForm : Mail de l'envoyeur
    'txtTo : Mail de destination
    'txtSubject = Objet
    'txtBody = contenu
    'txtAttach = chemin complet du fichier
End Sub
 
Public Sub CDOSendMail(SendFrom As String, _
                       SendTo As String, _
                       Subject As String, _
                       PlainTextBody As String, _
                       FullPathFileName As String)
    Dim cdoMail As CDO.Message
    Dim iBp As CDO.IBodyPart ' for IBodyPart on message
    Dim iBp1 As CDO.IBodyPart
    Dim Flds As ADODB.Fields
    Dim Stm  As ADODB.Stream
 
    Set cdoMail = New CDO.Message
    With cdoMail
        .From = SendFrom
        .To = SendTo
        .Subject = Subject
        ''Set iBp = .BodyPart
        Set iBp = cdoMail   '??
 
        ' TEXT BODYPART
        ' Add the body part for the text/plain part of message
        Set iBp1 = iBp.AddBodyPart
 
        ' set the fields here
        Set Flds = iBp1.Fields
        Flds("urn:schemas:mailheader:content-type") = "text/plain; charset=""iso-8859-1"""
        Flds.Update
 
        ' get the stream and add the message
        Set Stm = iBp1.GetDecodedContentStream
        Stm.WriteText PlainTextBody
        Stm.Flush
 
        ' HTML BODYPART
        ' Do the HTML part here
        Set iBp1 = iBp.AddBodyPart
        ' set the content-type field here
        Set Flds = iBp1.Fields
        Flds("urn:schemas:mailheader:content-type") = "text/html"
        Flds.Update
        ' get the stream and add message HTML text to it
        Set Stm = iBp1.GetDecodedContentStream
        Stm.WriteText "<HTML><H1>this is some content for the body part object</H1></HTML>"
        Stm.Flush
 
        ' Now set the Message object's Content-Type header
        ' to multipart/alternative
        Set Flds = iBp.Fields
        Flds("urn:schemas:mailheader:content-type") = "multipart/alternative"
        Flds.Update
        .AddAttachment FullPathFileName
        .send '<-ici
    End With
End Sub