让outlook自动检查“空标题”和“空附件”

吉米 发表于 2007-07-04 15:04:45

不知道你是不是经常点完发送按钮后就叫起来,“啊呀,又忘了写主题了...”或者“完了,又把附件给漏了...”。下面我要推荐的文章就是教你如何让outlook自动帮你检查空主题和空附件功能的。

以下文章转自http://hi.baidu.com/%CA%AB%D5%B9/blog/item/c7f8dff9d032d658242df275.html,转载请注明出处。

在outlook 2003中添加“空邮件标题”和“空附件”检查功能
最近经常发现发Email的时候忘记写邮件标题或遗漏附件,于是在网上搜索相关检查工具。有幸,找到了两个,一个是专门检查“空标题”的,另外一个是检查”遗漏附件“。可是发现无法在outlook 2003中将这两个VB script加进去,于是乎,想到一个办法:为何不能吧这两个检查合并为一个检查呢?

说干就干,先把这两个别人写的VB script抄下来参考(1)和(2),然后将其合并为(3),主要修改的是关于Cancel的赋值和判断,增加了两个布尔变量(cancel_Subject , cancel_Attach)来保存两个弹出窗口的判断值:

1)Blank Subject

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
If TypeName(Item) <> "MailItem" Then Exit Sub

'CHECK FOR BLANK SUBJECT LINE
If Item.Subject = "" Then
Cancel = MsgBox("This message does not have a subject." & vbNewLine & _
"Do you wish to continue sending anyway?", _
vbYesNo + vbExclamation, "No Subject") = vbNo
End If
End Sub

2)Missing Attachment

' VBA program for Outlook, (c) Dan Evans. dan at danevans.co.uk
' Will check if your outgoing email mentions an attachment, but you've
' forgotten to attach it

' v1.03b of 29/7/05 - Modified by Leonard Slingerland (leonard at slingerland.biz) to have array of words rather than just one
' v1.03 of 10/8/04 - Modified to search through subject line as well as message body
' v1.02 of 16/10/02 - No change to code, but tested works with Outlook 2002 as well as Outlook 2000
' v1.01 of 23/9/01 - OK for "Attach" as well as "attach"
' v1.00 of 21/9/01 - Initial working version

Dim intRes As Integer
Dim strMsg As String
Dim strThismsg As String
Dim intOldmsgstart As Integer

' ADDED BY LS >>>
' - Does not search for "Attach", but for all strings in an array that is defined here
Dim sSearchStrings(3) As String
Dim bFoundSearchstring As Boolean
Dim i As Integer ' loop var for FOR-NEXT-loop
bFoundSearchstring = False

sSearchStrings(0) = "attach"
sSearchStrings(1) = "hereby"
sSearchStrings(2) = "bijlage" ' Dutch
sSearchStrings(3) = "hierbij" ' Dutch
' ADDED BY LS <<<

intOldmsgstart = InStr(Item.Body, "-----Original Message-----")
' intOldmsgstart is the location of where old/re/fwd msg starts. Will be 0 if new msg

If intOldmsgstart = 0 Then
strThismsg = Item.Body + " " + Item.Subject
Else
strThismsg = Left(Item.Body, intOldmsgstart) + " " + Item.Subject
End If
' The above if/then/else will set strThismsg to be the text of this message only,
' excluding old/fwd/re msg
' IE if the original included message is mentioning an attachment, ignore that
' Also includes the subject line at the end of the strThismsg string

' ADDED BY LS >>>
For i = LBound(sSearchStrings) To UBound(sSearchStrings)
If InStr(LCase(strThismsg), sSearchStrings(i)) > 0 Then
bFoundSearchstring = True
Exit For
End If
Next i
' ADDED BY LS <<<

If bFoundSearchstring Then
If Item.Attachments.Count = 0 Then
strMsg = "Dan Evans' Attachment Checker:" & Chr(13) & Chr(10) & "Your message mentions an attachment, but doesn't have one." & Chr(13) & Chr(10) & "Send the message anyway?"
intRes = MsgBox(strMsg, vbYesNo + vbDefaultButton2 + vbExclamation, "You forgot the attachment!")
If intRes = vbNo Then
' cancel send
Cancel = True
End If
End If
End If

3)Blank Subject & Missing Attachment

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
If TypeName(Item) <> "MailItem" Then Exit Sub

Dim cancel_Subject As Boolean
Dim cancel_Attach As Boolean


'CHECK FOR BLANK SUBJECT LINE
If Item.Subject = "" Then
cancel_Subject = MsgBox("This message does not have a subject." & vbNewLine & _
"Do you wish to continue sending anyway?", _
vbYesNo + vbExclamation, "No Subject") = vbNo
End If

'CHECK FOR FORGETTING ATTACHMENT
Dim intRes As Integer
Dim strMsg As String
Dim strThismsg As String
Dim intOldmsgstart As Integer

' ADDED BY LS >>>
' - Does not search for "Attach", but for all strings in an array that is defined here
Dim sSearchStrings(1) As String
Dim bFoundSearchstring As Boolean
Dim i As Integer ' loop var for FOR-NEXT-loop
bFoundSearchstring = False

sSearchStrings(0) = "attach"
sSearchStrings(1) = "enclose"

' ADDED BY LS <<<

intOldmsgstart = InStr(Item.Body, "-----Original Message-----")
' intOldmsgstart is the location of where old/re/fwd msg starts. Will be 0 if new msg

If intOldmsgstart = 0 Then
strThismsg = Item.Body + " " + Item.Subject
Else
strThismsg = Left(Item.Body, intOldmsgstart) + " " + Item.Subject
End If
' The above if/then/else will set strThismsg to be the text of this message only,
' excluding old/fwd/re msg
' IE if the original included message is mentioning an attachment, ignore that
' Also includes the subject line at the end of the strThismsg string

' ADDED BY LS >>>
For i = LBound(sSearchStrings) To UBound(sSearchStrings)
If InStr(LCase(strThismsg), sSearchStrings(i)) > 0 Then
bFoundSearchstring = True
Exit For
End If
Next i
' ADDED BY LS <<<

If bFoundSearchstring Then
If Item.Attachments.Count = 0 Then
strMsg = "Attachment Checker:" & Chr(13) & Chr(10) & "Your message mentions an attachment, but doesn't have one." & Chr(13) & Chr(10) & "Send the message anyway?"
intRes = MsgBox(strMsg, vbYesNo + vbDefaultButton2 + vbExclamation, "You forgot the attachment!")
If intRes = vbNo Then
' cancel send
cancel_Attach = True
End If
End If
End If

If (cancel_Subject Or cancel_Attach) = True Then
Cancel = True
End If

End Sub


----------------------
如何使用它呢,你可以选择(1)或(2)满足自己的需要,或者用(3)来使用两种检查功能。下面来简单介绍怎么用,或者说怎么嵌入到outlook 2003中:
a. 打开outlook
b. 按“Alt + F11” 键来打开VB Script
c. 点击左侧树状目录最下面的“ThisOutlookSession”,看到右边出现空白的编辑窗口
d. 把(1)或(2)或(3)的代码拷贝到编辑窗口,保存,退出VB Script编辑。(不用重启Outlook)

就这么简单,自己写个email测试一下功能看看?能否看到提示窗口?

经过测试,在Outlook 2002/2003上通过。

对于“Missing Attachment”功能,补充两句:这段代码是检查Email正文中的关键词:attach, enclose,来判断是否要求添加附件。根据自己需要,可以添加关键词,比如“附件”等等。代码中有:
Dim sSearchStrings(1) As String

sSearchStrings(0) = "attach"
sSearchStrings(1) = "enclose"
如果要增加关键词,就相应增加sSearchStrings(1)中的数字(如果有N个关键词,就为N-1),然后在下面添加相应的关键词,如:
sSearchStrings(2) = "附件"

好了,你也可以自己定制其它功能哦!欢迎讨论!

关键词(Tag): 转载 邮件 主题 outlook 附件

Synergy -- 让多台电脑跨系统共享键盘、鼠标以及剪贴板

吉米 发表于 2007-06-25 21:44:11

我平常工作中使用两台电脑:一台笔记本winXP操作系统,用于一般工作;另一台Linux工作站,用于应用开发。经常需要在两台电脑间切换使用,一会儿用这个键盘打打字,一会儿又用那个鼠标动一动,有时转来转去多了都觉得挺晕的。虽然现在有专门的共享hub可以实现切换,可是毕竟要添置一个额外的硬件,而且我们同事也出现过因此把笔记本端口烧坏的例子,总是不大放心。另外更麻烦的是,要在两台电脑间编辑拷贝一些文件的话,必须通过FTP服务来传输文件到本地才行。

那么是不是有什么软件可以解决这个问题呢?很幸运,我找到了一款免费软件Synergy -- 专门用于多台电脑跨系统共享鼠标、键盘以及剪贴板等的软件。这个软件是基于GPL的免费开源软件,支持Windows 9x/NT/XP、Linux/Unix和Mac等操作系统,必须工作在TCP/IP网络环境下。

简单的说,Synergy工作在Client-Server模式下,以其中一台机器为Server,其他机器可以作为Client连接到Server上,用户可以自定义Server端和Client端屏幕的相对位置。比如Server的屏幕处于Client的左边,即Client处于Server的右边,那么当Server的鼠标向左移动到Server屏幕区域外时,鼠标指针就出现在Client的屏幕上,此时键盘输入对Client端有效。反之,将鼠标向右移动到Client屏幕区域外时,鼠标指针就又回到了Server的屏幕上,此时键盘输入对Server端有效。所有终端的剪贴板是共享的,屏保也是同步的,很方便吧。

具体设置方面,windows下是图形化的界面,很容易操作。对于Linux系统,只能通过文本方式设置配置文件。不过不用害怕,它的主页上提供了详细的帮助说明,如果安装完windows版本会带有帮助文件供参考。

Synergy的下载地址,请点击这里

准备开张

吉米 发表于 2007-06-23 00:50:36

几年前开始兴起了博客,也跟着写了些日子,更多的是生活方面的内容。最近想记录一些技术方面的内容,觉得还是单独放个地方比较适合,于是想起还在这里申请过,不如拿出来专用。想法其实也有段日子了,一直没有动手,今天趁着有些热情,就此开张吧。