Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
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
Public Const SW_HIDE = 0 'Hide the opened window
'________________________________________________
Sub PrintItems
Dim objApp As Outlook.Application
Dim objNS As Outlook.Namespace
Dim objFolder As MAPIFolder
Dim objMsg As MailItem
Dim objAttach As Attachment
Dim strFile As String
Dim intC1 As Integer
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
'Get the folder containing the items to print
Set objFolder = objNS.GetDefaultFolder(olFolderInbox).Folders("Print")
'Move through the items collection
Set objMsg = objFolder.Items.GetFirst
Do While Not objMsg Is Nothing
'Print the e-mail
objMsg.PrintOut
'Move through the attachments collection
If objMsg.Attachments.Count > 0 Then
For intC1 = 0 To objMsg.Attachments.Count - 1
'Get the filename
Set objAttach = objMsg.Attachments.Item(intC1)
strFile = "c:\temp\" & objAttach.FileName
'Save the attachment
objAttach.SaveAsFile strFile
'Print it
ShellExecute Me.hWind, "print", strFile, _
vbNullString, vbNullString, SW_HIDE
Next
End If
Set objMsg = objFolder.Items.GetNext
Loop
'Delete all the files in c:\temp here if required
Set objAttach = Nothing
Set objMsg = Nothing
Set objFolder = Nothing
Set objNS = Nothing
Set objApp = Nothing
End Sub