Envoi pièces jointe avec Cdonts

fdthierry Messages postés 106 Date d'inscription lundi 24 novembre 2003 Statut Membre Dernière intervention 27 septembre 2019 - 5 nov. 2004 à 10:38
JBond34 Messages postés 1 Date d'inscription mardi 9 mars 2004 Statut Membre Dernière intervention 23 mars 2005 - 23 mars 2005 à 14:08
Bonjour,

Mieux qu'un long discours, voici mon code:

' Send by connecting to port 25 of the SMTP server.
Dim iMsg
Dim iConf
Dim Flds
Dim strMail

Const cdoSendUsingPort = 2
Const CdoLow = 0 ' Low importance
Const CdoNormal = 1 ' Normal importance (default)
Const CdoHigh = 2 ' High importance

set iMsg = CreateObject("CDO.Message")
set iConf = CreateObject("CDO.Configuration")

Set Flds = iConf.Fields

strBody = "Voici le corps du mail à envoyer."

' Set the CDOSYS configuration fields to use port 25 on the SMTP server.

With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.domaine.fr"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
.Update
End With

' Build HTML for message body.
strMail = "<HTML>"
strMail = strMail & "<HEAD>"
strMail = strMail & ""
strMail = strMail & "
Sauvegarde Outlook AGermain.

"
strMail = strMail & "
"
strMail = strMail & "
Le " & Now() & " :"
strMail = strMail & "

" & strBody & " "
strMail = strMail & "

Le Service Informatique."
strMail = strMail & ""
strMail = strMail & "</HTML>"

' Apply the settings to the message.
With iMsg
Set .Configuration = iConf
.To = "Expediteur@domaine.fr"
.From = "Destinataire@domaine.fr"
.Subject = "Envoi mail via un script VBS"
.AttacheFile "C:\Temp\Toto.log"
.HTMLBody = strMail
.Send
End With

' Clean up variables.
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing

MsgBox "Mail Sent!"

Je n'arrive pas à joindre de pièces jointes, ou est mon pb svp?
Il bloque systématiquement sur AttachFile.

Amicalement,
Thierry

1 réponse

JBond34 Messages postés 1 Date d'inscription mardi 9 mars 2004 Statut Membre Dernière intervention 23 mars 2005
23 mars 2005 à 14:08
.AddAttachment
0
Rejoignez-nous