Bonjour le forum,
petit soucis avec une macro, lorsque j'essaye d'envoyer mon mail et que j'utilise le nouvelle version de Outlook j'ai une erreur liée à l'erreur spécifique 429.
Quelqu'un pourrais m'aider svp.
Merci d'avance
' Envoie du mail
Public Sub EnvoyerMail(RepertoryPath$, FileName$)
Dim oOutlook As Outlook.Application
Dim oMailItem As Outlook.MailItem
' On tente de créé un objet Outlook en 2 essais, on vérifie si la création de l'objet Outlook remonte une erreur
On Error Resume Next
Set oOutlook = GetObject(, "Outlook.Application")
' Vérification du retour d'erreur, si supèrieur à 0, pas bon
If Err.Number > 0 Then
' Si erreur spécifique 429 on interrompt la macro, sinon 2ème essai
If Err.Number = 429 Then
MsgBox "Error when opening Outlook"
Exit Sub
Else
Err.Clear
Set oOutlook = CreateObject("Outlook.application")
End If
If Err.Number > 0 Then
MsgBox "Error when opening Outlook"
Exit Sub
End If
End If
' Création d'un objet mail avec vérification d'une remontée d'erreur
On Error Resume Next
Set oMailItem = oOutlook.CreateItem(0)
If Err.Number > 0 Then
MsgBox "Error when generating the mail"
Else
Dim sBody$
sBody = Sheets("Information Page").Range("C32").Value
With oMailItem
.To = Func_additionnel.DefinitionDestinataire(Sheets("Drop List").ListObjects("Tab_To"))
.CC = Func_additionnel.DefinitionDestinataire(Sheets("Drop List").ListObjects("Tab_Cc"))
.Subject = "OPR request for the project " & Sheets("OPR info").Range("B11").Text & " - " & Sheets("Information Page").Range("C13").Text
.BodyFormat = olFormatHTML 'olFormatPlain
.Body = Func_additionnel.InsertionCommentaireMail(Sheets("OPR info").Range("B2").Value, sBody)
.Attachments.Add RepertoryPath & FileName
.Display ' A décommenter si le mail dois s'afficher avant envoi manuel
'.Send ' A décommenter si le mail dois s'envoyer directement
End With
End If
' On supprime les objets de la mémoire
Set oOutlook = Nothing
Set oMailItem = Nothing
End Sub