|
很好的一个VBA,
PS:
.Display‘如果是outlook 2007 将此行注释掉
应该是OL2003时注释掉这一句?我的是2003,要注释掉这一句后才能用。
还有:
当我将上述VBA与下述VBA共存时,则上述VBA不能用,不知道是什么原因?
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim lngres As Long
If InStr(1, UCase(Item.Body), "附件") Or InStr(1, UCase(Item.Body), "附档") <> 0 Then
If Item.Attachments.Count = 0 Then
lngres = MsgBox("邮件内容中包含'附件', 但是没有发现附件 – 仍然发送?", _
vbYesNo + vbDefaultButton2 + vbQuestion, "你要求我向你提示...")
If lngres = vbNo Then Cancel = True
End If
End If
End Sub
Sub olAddAttachedFileTitle()
Dim mFileName, mSubject As String
Dim iPos As Integer
Dim i As Integer
Set CurrentMail = ActiveInspector.CurrentItem
If TypeName(CurrentMail) <> "MailItem" Then
MsgBox "当前活动窗口不是一封邮件"
Else
If CurrentMail.Attachments.Count > 0 Then '必须是在有附件的情况下
For Each Item In CurrentMail.Attachments
mFileName = Item.FileName '取得附件文件名称(包括后缀)
mLen = Len(mFileName) '取得名称长度
For i = mLen To 1 Step -1
If Mid(mFileName, i, 1) = "." Then
iPos = i '.的位置
End If
Next i
iPos = iPos - 1
mFileName = Left(mFileName, iPos) '去掉了后缀的文件名称
If mSubject = "" Then
mSubject = mFileName
Else
mSubject = mSubject & ", " & mFileName
End If
Next
CurrentMail.Subject = mSubject '把得到的名称写入邮件主题
Else
MsgBox "当前邮件没有附件"
End If
End If
End Sub
另外,上述VBA签名能否设置相应的格式和字体? |
|