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
| Option Explicit
Sub Tst()
Dim sFichier As String
sFichier = ThisWorkbook.Path & "\" & "GESTION LAURENT.xlsm"
EnvoiCDO sFichier
End Sub
Private Sub EnvoiCDO(sNomFichier As String)
Dim Msg As Object
Dim Conf As Object
Dim sBody As String
Dim Flds As Variant
Set Msg = CreateObject("CDO.Message")
Set Conf = CreateObject("CDO.Configuration")
Conf.Load -1
Set Flds = Conf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
' à adapter à votre contexte : message sortant
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.sfr.fr"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587
.Update
End With
sBody = "Test"
With Msg
Set .Configuration = Conf
' à adapter à votre contexte
.To = "societe@ut.fr"
.CC = ""
.BCC = ""
' à adapter à votre contexte
.From = """Lux Techni Peinture"" <x@gmail.com>"
.Subject = Range("c22")
.TextBody = sBody
.Send
End With
Set Conf = Nothing
Set Msg = Nothing
End Sub |