?
Solved

outlook 2010 print sent emails

Posted on 2011-03-15
8
Medium Priority
?
803 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 2000 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Many people use more than one email account and so it becomes difficult for them to manage them when they use separate accounts,  so, in this article, I have shared an easy way to add Other Mail Accounts in your Google Inbox. It helps to combine all…
Outlook for dependable use in a very small business   This article is about using the Outlook application (part of Microsoft Office) in a very small business, or for homeowners where dependability and reliability are critical requirements. This …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Suggested Courses

770 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