![]() |
|
#2
|
||||
|
||||
|
If you put the following in the ThisOutlookSession module, and run the Application_Startup macro (or restart Outlook - not forgetting to save the project) when a file is moved to the Maria Alencar (which I assume is you) sub folder, you will hear the Windows Notify sound from C:\Windows\Media and see a message box.
Note that Outlook is very fussy about security, so you will almost certainly need to self certify the macro project - see http://www.gmayor.com/create_and_emp...gital_cert.htm Code:
Option Explicit
#If Win64 Then
Private Declare PtrSafe Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
#Else
Private Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
#End If
Private WithEvents Items As Outlook.Items
Private Sub Application_Startup()
Dim olApp As Outlook.Application
Set olApp = Outlook.Application
Set Items = GetNS(olApp).GetDefaultFolder(olFolderInbox).folders("Maria Alencar").Items
End Sub
Private Sub Items_ItemAdd(ByVal item As Object)
On Error GoTo ErrorHandler
PlayASound "Notify"
MsgBox "There's a new item in Mary's folder."
ProgramExit:
Exit Sub
ErrorHandler:
Beep
MsgBox Err.Number & " - " & Err.Description
Resume ProgramExit
End Sub
Private Function GetNS(ByRef app As Outlook.Application) As Outlook.NameSpace
Set GetNS = app.GetNamespace("MAPI")
End Function
Private Sub PlayASound(ByVal pSound As String)
If Dir(pSound, vbNormal) = "" Then
pSound = Environ("WinDir") & "\Media\" & pSound
If InStr(1, pSound, ".") = 0 Then pSound = pSound & ".wav"
If Dir(pSound, vbNormal) = vbNullString Then
Beep
Exit Sub
End If
End If
DoEvents
sndPlaySound32 pSound, 0&
DoEvents
lbl_Exit:
Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Rule to forward email using rule to me@onenote.com | anony1 | OneNote | 2 | 02-04-2023 02:39 PM |
| create rule to copy sent items to specified folder | shmu | Outlook | 0 | 12-15-2015 04:08 AM |
Mail merge from excel - need to create sheets and create a table
|
bluenosebex | Mail Merge | 5 | 08-02-2015 05:34 PM |
| Rule to turn off a rule | tiger10012 | Outlook | 2 | 02-23-2013 09:50 AM |
Create Rule to forward message to mobile#
|
JoyConner | Outlook | 1 | 04-21-2011 05:44 PM |