-
As a warm-up, you could try this (paste everything in a module in outlook and create a rule for every mail that comes in. When placed on top, it will execute before every other rule.). For the moment it will log every mail that comes in and writes the sendername and subject to an excel file. You need to install that express clickyes utility to click away the security warnings that outlook will give.
Attached you'll find the excel file I used for this purpose. Save it in c:\data\mail_log under the name mail_log.xls . I hope this will give you a boost in the right direction.[vba]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 Mail_log(myItem As Outlook.MailItem)
Dim i As Long
Dim oExcel As Object
Dim oWb As Object
Dim oWs As Object
Set oExcel = Application.CreateObject("Excel.Application")
oExcel.Visible = False
'C:\Data\Mail_log\Mail_log.xls is the file where we log
'all the mails that come in
Set oWb = oExcel.Workbooks.Open("C:\Data\Mail_log\Mail_log.xls")
Set oWs = oWb.Worksheets(1)
i = 2
Do While oWs.Range("A" & i).Value <> vbNullString
i = i + 1
Loop
Call PrepareClickYes
oWs.Range("A" & i) = myItem.SenderName
Call PerformClickYes
oWs.Range("B" & i).Value = myItem.Subject
oWb.Save
oWb.Close
Set oWs = Nothing
Set oWb = Nothing
Set oExcel = Nothing
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[/vba]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules