Solved

outlook 2010 print sent emails

Posted on 2011-03-15
8
781 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
ID: 35144801
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
ID: 35145201
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
ID: 35145460
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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 5

Author Comment

by:deibel
ID: 35146119
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
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 35146186
Not that I am aware of.

Chris
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 35146208
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
ID: 35146491
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
ID: 35146556
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
Read this checklist to learn more about the 15 things you should never include in an email signature.
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: …

774 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