XL 2016 Envoi feuille excel par mail CDO via AOL

PaulTrax

XLDnaute Nouveau
Bonjour à tous,
je galère depuis quelques jours pour envoyer une feuille excel ( Bon de commande) que j'ai créer par CBO via mon serveur AOL.
Je me sert de Outlook mais je dois l'ouvrir pour envoyer ma feuille.
Voici mon code repris et modifié pour cette feuille avec une erreur Object à l'arrivée.
Si parmi vous vous connaisez et je n'en doute pas, cette solution, merci d'avance.

Private Sub envoi_aol()
'Déclaration des variables
' copie le fichier en PDF dans le répertoire commandes mail avec le nom et la date
'Déclaration des variables
Dim nompdf As String
Dim dossier As String
Dim LaDate As String
Dim Four As String
Dim NomFeui As String
Dim MailFour As String
Dim x As Long

MailFour = Sheets("Bon_de_commande ").Range("H12")
LaDate = Format(Now, "yyyy_mm_dd")
Four = Sheets("Bon_de_commande ").Range("H6")
dossier = "Z:\Réservoir\Atelier\EBP\Bon de commande2019\Juillet"
NomFeui = "Bon_de_commande"
nompdf = dossier & "\" & NomFeui & "_" & Four & "_" & LaDate
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=nompdf & ".pdf", Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False

Dim CDO_Mail_Object As Object
Dim CDO_Config As Object
Dim SMTP_Config As Variant
Dim Email_Subject, Email_Send_From, Email_Send_To, Email_Cc, Email_Bcc, Email_Body, Email_Addattachment As String
Email_Subject = "Nouvelle commande"
Email_Send_From = "moi@aol.com"
Email_Send_To = MailFour
Email_Send_Boddy = ""
Email_Send_AddAttachment = nompdf & ".pdf"

Dim MailApp As Object
Dim MaiiItem As Object
Dim MailAtt As Object

Set CDO_Mail_Object = CreateObject("CDO.Message")
On Error GoTo CDOdebugs

Set CDO_Config = CreateObject("CDO.Configuration")
CDO_Config.Load -1
Set SMTP_Config = CDO_Config.Fields

With SMTP_Config
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.aol.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "mon identifiant"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "Mot de passe"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 15
.Update
End With

With CDO_Mail_Object
Set .Configuration = CDO_Config
End With

CDO_Mail_Object.Subject = Email_Subject
CDO_Mail_Object.From = Email_Send_From
CDO_Mail_Object.To = Email_Send_To
CDO_Mail_Object.BCC = Email_Send_Boddy
CDO_Mail_Object.AddAttachment = Email_Send_AddAttachment
CDO_Mail_Object.Send

CDOdebugs:
If Err.Description <> "" Then MsgBox Err.Description
MsgBox "Votre Message a bien été envoyé à :" & Chr(10) & MailFour

End Sub
 

Discussions similaires


Haut Bas