Advertisement
Guest User

Untitled

a guest
May 16th, 2019
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.15 KB | None | 0 0
  1. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
  2.     (ByVal hwnd As Long, ByVal lpOperation As String, _
  3.     ByVal lpFile As String, ByVal lpParameters As String, _
  4.     ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
  5. Option Explicit
  6. Private WithEvents inboxItems As Outlook.Items
  7. Private Sub Application_Startup()
  8.   Dim outlookApp As Outlook.Application
  9.   Dim objectNS As Outlook.NameSpace
  10.  
  11.   Set outlookApp = Outlook.Application
  12.   Set objectNS = outlookApp.GetNamespace("MAPI")
  13.   Set inboxItems = objectNS.GetDefaultFolder(olFolderInbox).Items
  14. End Sub
  15. Private Sub inboxItems_ItemAdd(ByVal Item As Object)
  16. On Error GoTo ErrorHandler
  17. Dim Msg As Outlook.MailItem
  18. Dim MessageInfo
  19. Dim fichier
  20. Dim Repertoire
  21. Dim Result
  22. If Item.SenderEmailAddress = "simon.arsenault@xim3ng.com" Then
  23.     Set fichier = Item.Attachments
  24.     Repertoire = "C:\OutTemp\"
  25.     fichier(1).SaveAsFile Repertoire & fichier(1).FileName
  26.     ShellExecute 0, "printto", fichier(1).FileName, "", "C:\OutTemp\", 0
  27. End If
  28. ExitNewItem:
  29.     Exit Sub
  30. ErrorHandler:
  31.     MsgBox Err.Number & " - " & Err.Description
  32.     Resume ExitNewItem
  33. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement