Chris_cs
08-14-2007, 01:39 AM
We have a rule where I work at the moment which prints out an email when it arrives in to the inbox of a mail account. The proble is that it trips up on emails which are sent in HTML. The rule is then switched off so alot of emails have to be printed manually.
I wanted to know if its possible to create a custom rule which will print incoming emails auomatically and be able to deal with HTML emails?
I'd appreciate any advice that anyone can give.
Chris_cs
08-15-2007, 02:33 AM
Ok, I found a link to this article which looks like the kind of thing I need: http://www.vbaexpress.com/kb/getarticle.php?kb_id=522
I've been playing around with it but need it to look at the inbox and to also check the email type.
Any ideas?
Charlize
09-05-2007, 12:54 AM
Take a look at this tryout. Will save every new mail first to a txt file and print that file to the default printer. You will also need the click yes routine (can be found here at the site under tools --- or something ---). Place this in a module.
Option Explicit
' Declare Windows' API functions
' To be used with ExpressClick Yes
Private Declare Function RegisterWindowMessage _
Lib "user32" Alias "RegisterWindowMessageA" _
(ByVal lpString As String) As Long
Private Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" (ByVal lpClassName As Any, _
ByVal lpWindowName As Any) As Long
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
'These are used by the utility ClickYes Freeware
Public wnd As Long
Public uClickYes As Long
Public Res As Long
Sub printing_newmails(myItem As Outlook.MailItem)
Dim i As Long
'prepare the clickyes utility to click when security
'window pops up
Call PrepareClickYes
'directory c:\tempmail must be present
myItem.SaveAs "C:\tempmail\tempmail.txt", olTXT
'push the ok button on the security window
Call PerformClickYes
Shell "C:\Windows\system32\notepad.exe C:\tempmail\tempmail.txt", vbNormalFocus
For i = 1 To 500: Next i
SendKeys "%", True
For i = 1 To 500: Next i
'probably f - file
'dutch b - Bestand
SendKeys "b", True
For i = 1 To 500: Next i
'probably p - print
'dutch d - afDrukken
SendKeys "d", True
For i = 1 To 500: Next i
SendKeys "%d", True
For i = 1 To 500: Next i
SendKeys "%", True
For i = 1 To 500: Next i
SendKeys "b", True
For i = 1 To 500: Next i
'probably c - close
'dutch a - Afsluiten
SendKeys "a", True
For i = 1 To 500: Next i
End Sub
Sub PrepareClickYes()
'called before attempting to manipulate a message
uClickYes = RegisterWindowMessage("CLICKYES_SUSPEND_RESUME")
wnd = FindWindow("EXCLICKYES_WND", 0&)
Res = SendMessage(wnd, uClickYes, 1, 0)
End Sub
Sub PerformClickYes()
'called directly after the code that manipulates
'a message. Clicks the yes and places the ClickYes utility
'back in suspend mode. When some other routine (that's not
'controlled by you) wants to do something with your
'messages, you still get that warning.
Res = SendMessage(wnd, uClickYes, 0, 0)
End Sub
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.