Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
- (ByVal hwnd As Long, ByVal lpOperation As String, _
- ByVal lpFile As String, ByVal lpParameters As String, _
- ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
- Option Explicit
- Private WithEvents inboxItems As Outlook.Items
- Private Sub Application_Startup()
- Dim outlookApp As Outlook.Application
- Dim objectNS As Outlook.NameSpace
- Set outlookApp = Outlook.Application
- Set objectNS = outlookApp.GetNamespace("MAPI")
- Set inboxItems = objectNS.GetDefaultFolder(olFolderInbox).Items
- End Sub
- Private Sub inboxItems_ItemAdd(ByVal Item As Object)
- On Error GoTo ErrorHandler
- Dim Msg As Outlook.MailItem
- Dim MessageInfo
- Dim fichier
- Dim Repertoire
- Dim Result
- If Item.SenderEmailAddress = "simon.arsenault@xim3ng.com" Then
- Set fichier = Item.Attachments
- Repertoire = "C:\OutTemp\"
- fichier(1).SaveAsFile Repertoire & fichier(1).FileName
- ShellExecute 0, "printto", fichier(1).FileName, "", "C:\OutTemp\", 0
- End If
- ExitNewItem:
- Exit Sub
- ErrorHandler:
- MsgBox Err.Number & " - " & Err.Description
- Resume ExitNewItem
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement