Solved

outlook 2010 print sent emails

Posted on 2011-03-15
8
796 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

What does UTC stand for?  “Coordinated Universal Time” – Think of this as the true time on Planet Earth that never changes with the exception of minor leap seconds here and there to account for the changes in the planet's rotation.   What does th…
In this step by step procedure, you will come to know the details of creating an Outlook meeting in 2007, 2010, 2013 & 2016.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
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…

726 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