Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

outlook 2010 print sent emails

Posted on 2011-03-15
8
Medium Priority
?
807 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you troubleshoot Outlook for clients, you may want to know a bit more about the OST file before doing your next job. IMAP can cause a lot of drama if removed in the accounts without backing up.
The core idea of this article is to make you acquainted with the best way in which you can export Exchange mailbox to PST format.
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 …
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: …

971 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