Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   NewMailEx event not Triggered (http://www.outlookbanter.com/outlook-vba/101264-newmailex-event-not-triggered.html)

savindrasingh March 24th 10 09:14 AM

NewMailEx event not Triggered
 

Hello experts,

I am working on a macro to automate the processing of incoming mails
using below code:


Code:
--------------------
Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
Dim xlApp As New Excel.Application
Dim xlBook As New Excel.Workbook
Dim varEntryIDs, objItem
Dim i As Integer

Const OLECMDID_COPY = 12
Const OLECMDID_SELECTALL = 17
Const OLECMDEXECOPT_DODEFAULT = 0
Const OLECMDEXECOPT_PROMPTUSER = 1
Const OLECMDEXECOPT_DONTPROMPTUSER = 2
Const OLECMDEXECOPT_SHOWHELP = 3

Set ie = CreateObject("internetexplorer.application")

varEntryIDs = Split(EntryIDCollection, ",")
For i = 0 To UBound(varEntryIDs)
Set objItem = Application.Session.GetItemFromID(varEntryIDs(i))
If Left(objItem.Subject, 7) = "Action:" Then
ChDir ("C:\Temp")
TimeStamp = Format(Date, "dd-MM-yyyy") & Format(Time, "_HH_MM_SS")
OutFile = "Dss" & TimeStamp & ".html"
objItem.SaveAs "C:\Temp\" & OutFile, olHTML
url = "file:///C:/Temp/" & OutFile
Set xlBook = xlApp.Workbooks.Add(1)
With ie
.Top = 1
.Left = 1
.Height = 400
.Width = 500
.AddressBar = False
.MenuBar = False
.Toolbar = False
.Visible = True
.Navigate url
Do While .ReadyState 4
DoEvents
Loop

.ExecWB OLECMDID_SELECTALL, OLECMDEXECOPT_DONTPROMPTUSER
.ExecWB OLECMDID_COPY, OLECMDEXECOPT_DODEFAULT
End With
xlApp.Visible = True
xlApp.Application.DisplayAlerts = False
xlBook.Activate
xlApp.ActiveSheet.Paste
xlApp.Range("1:5").EntireRow.Delete
xlApp.Range("1:1").EntireRow.Hidden = True
xlApp.Range(xlApp.Range("A1").End(xlDown).Offset(1 , 0).Row & ":" & xlApp.Range("A1").End(xlDown).Offset(1, 0).Row + 3).EntireRow.Hidden = True
xlApp.Cells.SpecialCells(xlCellTypeVisible).Column s.WrapText = False
xlApp.Cells.SpecialCells(xlCellTypeVisible).Column s.AutoFit
xlApp.Cells.EntireRow.Hidden = False
xlBook.SaveAs FileName:="C:\Temp\Dss" & TimeStamp & ".xls", FileFormat:=xlNormal
xlBook.Close
xlApp.Application.DisplayAlerts = True
xlApp.Quit
ie.Quit
Kill "C:\Temp\" & OutFile
Kill ("C:\Temp\Dss" & TimeStamp & "_files\*.*")
RmDir ("C:\Temp\Dss" & TimeStamp & "_files")
End If
Next
End Sub

--------------------


This code is working perfectly on my PC but the same code is not
working on my colleague's PC. The NewMailEx event is not getting
triggered.
Any ideas?


--
savindrasingh
http://forums.slipstick.com


savindrasingh March 24th 10 09:46 AM

NewMailEx event not Triggered
 

I had just tested below code to see if the events are gettings triggered
but nothing happens when I recieve an email :-(


Code:
--------------------
Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
MsgBox "New mail !"
End Sub

--------------------


It should atleast show the msgbox but nothing happens :-( any IDEAS ??


--
savindrasingh

THANKS AND REGARDS,
SavindraSingh
http://forums.slipstick.com


Ken Slovak - [MVP - Outlook] March 24th 10 01:31 PM

NewMailEx event not Triggered
 
If VBA code is running on one machine and not another you need to check the
VBA and security settings for your versions of Outlook, which you don't
mention.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"savindrasingh" savindrasingh.48boda@invalid wrote in message
news:savindrasingh.48boda@invalid...

I had just tested below code to see if the events are gettings triggered
but nothing happens when I recieve an email :-(


Code:
--------------------
Private Sub Application_NewMailEx(ByVal EntryIDCollection As String)
MsgBox "New mail !"
End Sub

--------------------


It should atleast show the msgbox but nothing happens :-( any IDEAS ??


--
savindrasingh

THANKS AND REGARDS,
SavindraSingh
http://forums.slipstick.com




All times are GMT +1. The time now is 11:37 PM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com