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
| Sub mail_direct()
Const cdoBasic = 1
Dim admail As String, i As Integer
Dim messmail As String
Dim expediteur As String
On Error Resume Next
expediteur = InputBox("Adresse mail de l'Expéditeur", "ADRESSE ELECTRONIQUE", "ton adresse mail")
admail = InputBox("choisir le destinataire", "DESTINATAIRE", "ton destinataire")
'ci-dessous tu fais ce que tu veux
messmail = "Bonjour," & Chr(10) & "Ci-joint, notre nouvelle commande du " & Date & Chr(10) & Chr(10) & "Cordialement" & Chr(10) & Chr(10) & "M. LEMAIRE Dominique"
With CreateObject("CDO.Message")
If Err Then
'cidessous à adapter
MsgBox ("Problème de CDO non installé sur le serveur WEB")
Exit Sub
Else
.From = expediteur
.To = admail
'.Bcc = ""
.Subject = "ton sujet"
.TextBody = messmail
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = expediteur
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "ton mot de passe mail"
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp de ton serveur"
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 'à vérifier
.Configuration.Fields.Update
.AddAttachment fichierJoint 'une variable préalablement déclarée contenant ton fichier joint
.Send
If Err Then MsgBox "Le message n'a pas pu être expédié."
End If
On Error GoTo 0
End With
MsgBox "le fichier a logiquement été envoyé"
End Sub |
Partager