Bonjour le forum,
Je souhaite envoyer un ficher excel en PJ d'un mail via Outlook 2003 sans le message d'avertissement généré par Outlook.
J'ai trouvé le code nécessaire sur Internet mais j'ai cette erreur 
	
		
			
			
				erreur d'execution 438 propriete ou méthode non gérée par cet objet
			
		
 
	 
 voici le code
	
	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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
   | Sub Envoi_chef()
 
Application.ScreenUpdating = False
Application.DisplayAlerts = False
 
Set wbk = ActiveWorkbook
Set shrq = ActiveSheet
 
Quart = Range("V2").Value
stFichier = "Rapport " & Quart & ".xls"               'Nom Fichier temporaire
stFichierComp = "H:\Rapport\" & stFichier                 'Nom complet
 
stExistFich = Dir(stFichierComp)                       ' existence du fichier archive
 
If stExistFich = "" Then                               'Si n'existe pas on le crée
    Workbooks.Add
 
    Set arwbk = ActiveWorkbook
    Set shm = ActiveSheet
    shrq.Copy shm                                       'on copie la feuille dans le classeur
    shm.Delete                                          'on supprime les autres feuilles
    Sheets("feuil2").Delete
    Sheets("feuil3").Delete
    ActiveSheet.Name = Quart                           'on renomme la feuille restante par le quart
    Sheets(Quart).Unprotect ""
End If
'permet de rompre les liaisons
       ActiveWorkbook.BreakLink Name:="H:\Rapport\Rapport_données.xls", Type _
        :=xlExcelLinks
'on enregistre la feuille puis on referme
       arwbk.SaveAs Filename:=stFichierComp
       arwbk.Close
 
Set shm = Nothing
Set arwbk = Nothing
Set shrq = Nothing
Set wbk = Nothing
 
Dim oApp As Outlook.Application
Set oApp = New Outlook.Application
Dim monmail As MailItem
Set monmail = oApp.CreateItem(olMailItem)
monmail.Subject = "test ss message de secu"
monmail.To = "toto@mail.fr"
monmail.Attachments.Add (("H:\Rapport\" & stFichier))
monmail.Save
Kill "H:\Rapport\" & stFichier
Dim strID As String
strID = monmail.EntryID
Call oApp.send_Monmail(strID) '=======>c'est ici que ça coince
Set monmail = Nothing
Set oApp = Nothing
 
'pour envoyer le fichier au chef d'unité via Outlook
'With Olmail
    '.To = 
'    .To = 
'    .Subject = "Rapport de quart"
 '   .Body = "essai d'envoi rapport"
'affichage du mail puis envoi automatique par la fonction SendKeys
'    .Display
'    .Attachments.Add (("H:\Rapport \" & stFichier))
'    SendKeys "^{ENTER}"
 
'End With
 
Application.ScreenUpdating = True
Application.DisplayAlerts = True
 
End Sub | 
 Ca coince sur cette ligne
	
	Call oApp.send_Monmail(strID)
 et j'ai placé ce code dans this Outlook Session
	
	1 2 3 4 5
   | Sub send_Monmail(StrID As String)
Dim monmail
Set monmail = Application.GetNamespace("MAPI").GetItemFromID(StrID)
monmail.Send
End Sub | 
 Est ce que vous savez d'ou peut venir cette erreur.
Merci et bonne journée
PS:Comme vous pouvez le voir, j'ai essayé avec la méthode display sendkeys("^{ENTER}") mais elle marche de façon aléatoire.
						
					
Partager