Bonjour,
Si j'exécute ce code (avec un fichier joint), Outlook envoie bien le message :
Par contre, si je n'ai pas de fichier à joindre, de code
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 Sub EnvoyerMail() Dim olApplication As Object Dim olmail As Object Set olApplication = CreateObject("Outlook.Application") Set olmail = olApplication.CreateItem(olMailItem) With olmail .To = "destinataire@bidon.be" .Subject = "fghjklm" .Body = "ghjkl" .Attachments.Add "c:\pdf\tst.pdf" .Send End With End Sub
génère cette erreur :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 Sub EnvoyerMail() Dim olApplication As Object Dim olmail As Object Set olApplication = CreateObject("Outlook.Application") Set olmail = olApplication.CreateItem(olMailItem) With olmail .To = "destinataire@bidon.be" .Subject = "fghjklm" .Body = "ghjkl" .Send End With End Sub
Quelqu'un peut-il expliquer pourquoi et comment faire pour empêcher l'erreur ?
Partager