如何在Outlook 2007中监控共享邮箱? [英] How to monitor a shared mailbox in outlook 2007?

查看:194
本文介绍了如何在Outlook 2007中监控共享邮箱?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我正在尝试基于Outlook 2007监控我们企业中的文件夹。我想做的就是,只要一个新的电子邮件到达。它播放声音。就是这样。

我在网上遇到过几种解决方案。但他们中的大多数人已经采取了这个解决方案。我不太喜欢编程。但还是试一试。这是我迄今为止能够整理的代码。



Public Const SOUND_TO_PLAY =C:\ Windows \ MediaA.Notify.wav

Public Const SND_ASYNC =&H1



公共声明函数sndPlaySound _

Libwinmm.dll别名sndPlaySoundA_

(ByVal lpszSoundName As String,_

ByVal uFlags As Long)_

As Long

Option Explicit

Dim MailItemsCount As Integer

私有折叠1作为Outlook.MAPIFolder

私有WithEvents colItems1作为Outlook.Items



私有子Application_Startup()

'在此处插入文件夹名称!

设置Fold1 = Application.GetNamespace(MAPI)。文件夹(要监视的文件夹的名称)。文件夹(收件箱 )

设置colItems1 = Fold1.Items

MailItemsCount = colItems1.Items.Count

如果colItems1.Items.Count> MailItemsCount然后

sndPlaySound SOUND_TO_PLAY,SND_ASYNC

结束如果

结束次级



Private Sub Application_Quit()

'清理

Set Fold1 = Nothing

设置colItems1 = Nothing

End Sub



现在这些是我面临的问题。

我已将此代码放在ThisOutlookSession中,但是当我尝试编译它时,它会给出错误消息:编译错误:常量,固定长度字符串,数组,用户定义类型和Declare语句不允许作为对象模块的公共成员。



当我将常量声明更改为Private时,错误消失。但是,当我运行代码时没有任何反应。



第二个问题:是,以下用法,正确的逻辑来实现我想要实现的目标。我的意思是,一旦新邮件到达共享邮箱,它会播放声音吗?



设置colItems1 = Fold1.Items

MailItemsCount = colItems1.Items.Count

如果colItems1.Items.Count> MailItemsCount然后

sndPlaySound SOUND_TO_PLAY,SND_ASYNC

结束如果



第三件事是,我的文件夹我尝试访问是基于交换的共享邮箱。

这是访问这样一个邮箱的正确方法:



设置Fold1 = Application.GetNamespace(MAPI)。文件夹(要监控的文件夹的名称)。文件夹(收件箱)



非常感谢您对此事的帮助。

解决方案

Hi Guys,

I am trying to monitor a folder in our enterprise based on Outlook 2007. All i am trying to do is, as soon as a new email arrives. It plays a sound. And that's it.
There are couple of solutions that i have come across on the net. But most of them have taken this solution a bit too far. I am not very good with programming. But still gave it a try. This is the code that i have been able to put together so far.

Public Const SOUND_TO_PLAY = "C:\Windows\Media\Notify.wav"
Public Const SND_ASYNC = &H1

Public Declare Function sndPlaySound _
Lib "winmm.dll" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, _
ByVal uFlags As Long) _
As Long
Option Explicit
Dim MailItemsCount As Integer
Private Fold1 As Outlook.MAPIFolder
Private WithEvents colItems1 As Outlook.Items

Private Sub Application_Startup()
'Insert the folder names here!
Set Fold1 = Application.GetNamespace("MAPI").Folders("Name of the folder to monitor").Folders("Inbox")
Set colItems1 = Fold1.Items
MailItemsCount = colItems1.Items.Count
If colItems1.Items.Count > MailItemsCount Then
sndPlaySound SOUND_TO_PLAY, SND_ASYNC
End If
End Sub

Private Sub Application_Quit()
'Clean Up
Set Fold1 = Nothing
Set colItems1 = Nothing
End Sub

Now these are the issues that i am facing.
I have placed this code in ThisOutlookSession, But when i try to compile it, It gives the error message saying: Compile Error : Constants, Fixed-length strings, arrays, user-defined types and Declare statement not allowed as Public members of object modules.

When i change declaration of constants to Private, the errors disappear. But, when, I run the the code nothing happens.

Second issue: Is, the below usage, the right logic to achieve what i am trying to achieve. I mean will it play the sound as soon as a new mail arrives in the shared mailbox?

Set colItems1 = Fold1.Items
MailItemsCount = colItems1.Items.Count
If colItems1.Items.Count > MailItemsCount Then
sndPlaySound SOUND_TO_PLAY, SND_ASYNC
End If

And the third thing is, the folder that i am trying access is an exchange based shared mailbox.
Is this the right way to access such a mailbox :

Set Fold1 = Application.GetNamespace("MAPI").Folders("Name of the folder to monitor").Folders("Inbox")

Your help in the matter is greatly appreciated.

解决方案

这篇关于如何在Outlook 2007中监控共享邮箱?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆