Sub envoi_Fiche_Matériel()
' Avant de lancer cette macro : Dans l'éditeur VBA, faire
' Menu / Outils / Références... /
' et cocher "Microsoft Outlook 14.0 Object Library"
Dim répertoireAppli As String, olapp As New Outlook.Application, msg As MailItem, s As String
Application.ScreenUpdating = False
répertoireAppli = ActiveWorkbook.Path
'on crée le fichier PDF dans le même fichier source
Sheets("Fiche matériel").ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
ActiveWorkbook.Path & "\" & "Fiche matériel.pdf"
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Sheets("Destinataires").Activate
Range("A11").Select
Do While Not IsEmpty(ActiveCell)
s = s & ActiveCell.Value & "; "
ActiveCell.Offset(1, 0).Select
Loop
s = Left$(s, Len(s) - 2)
Set msg = olapp.CreateItem(olMailItem) ' Envoi par mail
msg.To = s
msg.Subject = Range("A2").Value
msg.Body = Range("A5").Value & Chr(13) & Chr(13) & Range("A8").Value & Chr(13) & Chr(13)
'attache le fichier au message
msg.Attachments.Add répertoireAppli & "\Fiche matériel.pdf"
msg.Send
MsgBox "La fiche matériel a bien était envoyée aux destinataires ."
End Sub
Sub lit_messagerie()
Dim olapp As Outlook.Application 'penser à Outils/Références Outlook
Dim olns As Outlook.Namespace
Dim olmf As Outlook.MAPIFolder
Dim obj As Object
Set olapp = New Outlook.Application
Set olns = olapp.GetNamespace("mapi")
Set olmf = olns.GetDefaultFolder(olFolderInbox)
For Each obj In olmf.Items
MsgBox obj.Subject
Next
End Sub