Consulting

Results 1 to 3 of 3

Thread: Solved: Printing Sent Email

  1. #1
    VBAX Regular
    Joined
    Sep 2005
    Posts
    34
    Location

    Solved: Printing Sent Email

    Hi,

    I have a colleague who wants to print a hard copy each time she sends an email to a particular recipient.

    Is it possible to incorporate a little bit of VBA with Outlook rules to do the job. If so, please tell me how? Otherwise, how would you suggest I set this up?

    Thanks in advance.

  2. #2

  3. #3
    VBAX Regular
    Joined
    Sep 2005
    Posts
    34
    Location

    Thanks for the pointer

    Based upon the start you gave me here is what I came up with:

    Objective
    All emails sent to a particular recipient need to be printed at the time they are sent.

    Logic
    Using the standard rules function any outgoing emails can be checked and if addressed to a particular person a copy of the email can saved in a separate folder. Using the Outlook programming language (VBA - Visual Basic for Applications) it is possible for Outlook to continually monitor the specific folder and, whenever an email is saved to it, the user can be asked if they want it to be printed. After printing the copy email is deleted. If the user does not want to print it the copy email is deleted.

    Limitations
    Outlook will print to whichever printer was the default printer when Outlook was started. If the default printer is changed whilst Outlook is running then Outlook must be closed and restarted to pick up the correct printer. It is not possible using this programming to choose a printer at the time of sending the email.

    Only tested with Outlook 2003.

    Setting up:
    Rule
    Inbox
    Tools
    Rules and Alerts
    New Rule
    Start from blank rule
    Check messages after sending
    Next
    Sent to people or distribution list (then specify details by clicking on link)
    Next
    Move a copy to specified folder (then specify details by clicking on link)
    Next
    Next
    Specify a name at the top of the dialog if desired
    Finish

    Folder
    Inbox
    Right click on "Mailbox - your name"
    New folder
    Make the name Temp
    OK

    Inserting VBA Code
    Inbox
    ALT-F11 (to open the editor)
    Copy the code into the right hand window (you may need to left click on ThisOutlookSession to open the window)
    Close Outlook and restart it.

    VBA code
    [VBA]Dim WithEvents TargetFolderItems As Items
    Private Sub Application_Startup()
    Dim ns As Outlook.NameSpace
    Set ns = Application.GetNamespace("MAPI")
    Set TargetFolderItems = ns.Folders.item("Mailbox - XXXXXXXXXXXXXX").Folders.item("Temp").Items
    Set ns = Nothing
    End Sub
    Private Sub TargetFolderItems_ItemAdd(ByVal item As Object)
    Dim AskUser as boolean
    Askuser = MsgBox("Do you want Outlook to print the email you just sent?" & vbCr _
    & vbcr & "Email Subject: " & item.Subject, vbYesNo)
    If Askuser = vbYes Then
    item.PrintOut
    End If
    item.Delete
    End Sub[/VBA]


    Thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •