Solved

outlook 2010 print sent emails

Posted on 2011-03-15
8
760 Views
Last Modified: 2012-05-11
Hello Experts

i want to print all the sent emails but i can only setup rules for incoming email.

i have a vbscript that doesent work. Can anybody tell me whats wrong with my script for printing sent mails

Dim WithEvents SentMailItems As Outlook.Items

Private Sub Application_Quit()
Set SentMailItems = Nothing
End Sub

Private Sub Application_Startup()
Set SentMailItems = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderSentMail).Items
End Sub

Private Sub SentMailItems_ItemAdd(ByVal Item As Object)
Item.PrintOut
End Sub
0
Comment
Question by:deibel
  • 5
  • 3
8 Comments
 
LVL 59

Expert Comment

by:Chris Bottomley
Comment Utility
Are macros enabled ... I have added a line to the startup routine to get a prompt o startup.  Once it is responding the line can of course be deleted.

At least that will be one cause identified.

Also no offfence but is all the the code in thisOutlookSession module?

Chris
Private Sub Application_Startup()
msgbox "Macros enabled"
Set SentMailItems = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderSentMail).Items
End Sub

Open in new window

0
 
LVL 5

Author Comment

by:deibel
Comment Utility
yes... macros are enabled and all code is in thisOutlookSession module
there is no promt after i add your code
0
 
LVL 59

Expert Comment

by:Chris Bottomley
Comment Utility
Okay then ... macros are disabled.

File | OPtions | Trust Centre | Macro settings.

Enable macros ... signed project or unsigned you may need to enable all.

Chris
0
 
LVL 5

Author Comment

by:deibel
Comment Utility
ok.. all macros are now enabled... the print window pops up.

can i print without the printer window coming up... like the fast print button? so no user interaction is required
0
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 
LVL 59

Expert Comment

by:Chris Bottomley
Comment Utility
Not that I am aware of.

Chris
0
 
LVL 59

Expert Comment

by:Chris Bottomley
Comment Utility
Ducking from suppressing teh display to bypassing it the following may help ... haven't had time to test it though:

http://www.mrexcel.com/forum/showthread.php?t=13057

Chris
0
 
LVL 5

Author Comment

by:deibel
Comment Utility
how do i need to implement that code in thisOutlookSession? if i just copy/paste it doesent work
0
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 500 total points
Comment Utility
I have used:


    fncScreenUpdating State:=False
    ActiveWorkbook.PrintOut
    fncScreenUpdating State:=True

With the snippet in a NEW normal code module.

Chris
Option Explicit

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
'// The SendMessage function sends the specified message to a window or windows.
'// The function calls the window procedure for the specified window and does not
'// return until the window procedure has processed the message.
'// The PostMessage function, in contrast, posts a message to a thread’s message
'// queue and returns immediately.
'//
'// PARAMETERS:
'//
'// hwnd
'// Identifies the window whose window procedure will receive the message.
'// If this parameter is HWND_BROADCAST, the message is sent to all top-level
'// windows in the system, including disabled or invisible unowned windows,
'// overlapped windows, and pop-up windows; but the message is not sent to child windows.
'// Msg
'// Specifies the message to be sent.
'// wParam
'// Specifies additional message-specific information.
'// lParam
'// Specifies additional message-specific information.
'//////////////////////////////////////////////////////////////////////////
'// The IsWindow function determines whether the specified window handle
'// identifies an existing window.

Private Declare Function IsWindow Lib "user32" (ByVal hwnd As Long) As Long
'// PARAMETERS:
'// hWnd
'// Specifies the window handle.
'//////////////////////////////////////////////////////////////////////////
'//

Private Declare Function InvalidateRect Lib "user32" (ByVal hwnd As Long, lpRect As Long, ByVal bErase As Long) As Long
Private Declare Function UpdateWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Public Function fncScreenUpdating(State As Boolean, Optional Window_hWnd As Long = 0)
Const WM_SETREDRAW = &HB
Const WM_PAINT = &HF

If Window_hWnd = 0 Then
    Window_hWnd = GetDesktopWindow()
Else
    If IsWindow(hwnd:=Window_hWnd) = False Then
        Exit Function
    End If
End If

If State = True Then
    Call SendMessage(hwnd:=Window_hWnd, wMsg:=WM_SETREDRAW, wParam:=1, lParam:=0)
    Call InvalidateRect(hwnd:=Window_hWnd, lpRect:=0, bErase:=True)
    Call UpdateWindow(hwnd:=Window_hWnd)
Else
    Call SendMessage(hwnd:=Window_hWnd, wMsg:=WM_SETREDRAW, wParam:=0, lParam:=0)
End If

End Function

Open in new window

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Get an idea of what you should include in an email disclaimer with these Top 5 email disclaimer tips.
This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now