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
|
Sub Envoi_CDO()
Dim CdoMessage As Object
Dim Fichier As Variant
ChDir "C:\Temp"
Fichier = Application.GetOpenFilename("Fichiers PDF (*.pdf), *.pdf")
If Fichier = False Then Exit Sub
Set CdoMessage = CreateObject("CDO.Message")
With CdoMessage
With .Configuration.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = "1"
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "xxxxx@gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "xxxxx"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = "true"
.Update
End With
.From = "xxxx@gmail.com"
.Subject = "Exemple"
.To = "xxxxxx@gmail.com"
.CC = ""
.BCC = ""
.TextBody = "test envoie"
.AddAttachment Fichier
.Send
End With
Set CdoMessage = Nothing
End Sub |
Partager