'################################### CDO envoi messagerie directement #################################
'CDO=Collaboration Data Object interface accédant à la couche MAPI (Ajouter réfce "Microsoft CDO for..."
Public Sub EnvoiMailCDO()
On Error Resume Next
Dim cMail As New CDO.Message
If Err Then
M$ = "CDO n'est pas installé !" & vbLf & _
"Vous devez cocher(du côté VB) la référence suivante:" & vbLf & _
"Microsoft CDO for..." & vbLf & _
"probablement: Microsoft CDO for Windows 2000 Library"
MsgBox M$, vbCritical, "Erreur référence"
On Error GoTo 0: Err.Clear
Exit Sub
End If
'>>>>>>>>>>> init var utiles <<<<<<<<<<<<<<<
' à la question 2 / Comment affecter comme titre de mail la cellule C11 ?
' il suffit de mettre Sujet = range("C11").value
AdresExpediteur = "" '<<< à voir ???
AdresDestinataire = "" '<<< à voir ???
Sujet = "" '<<< à voir ???
Message = "" '<<< à voir ???
CheminFichier = "" '<<< à voir ???
'envoi directement NET messagerie
Application.ScreenUpdating = False
On Error GoTo ErreurNET
With cMail
.From = AdresExpediteur
.To = AdresDestinataire
.Subject = Sujet
.TextBody = Message
.AddAttachment (CheminFichier)
.Send
End With
'
On Error GoTo 0: Err.Clear
Application.ScreenUpdating = True
Exit Sub
'---------------------------------------------------
ErreurNET:
Msg$ = "Erreur " & Err.Source & " No " & Err.Number
Msg$ = Msg$ & vbLf & vbLf & Err.Description
T$ = "Envoi Mail: Problème de connexion !?"
MsgBox Msg$, vbCritical, T$, Err.HelpFile, Err.HelpContext
On Error GoTo 0: Err.Clear
Application.ScreenUpdating = True
End Sub