我一直在outlook 2010中使用以下代码提醒我,如果我在电子邮件中引用了附件,却忘记了附加任何内容,请添加附件。然而,我想知道是否有一种方法只检查我写的文本(而不是在回复电子邮件时检查引用的文本)。由于公司的安全设置,我无法添加外接程序,因此需要依赖VBA。
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
‘ Pops up a reminder if the word “attach” is found but there is no attachment on your email.
Dim m As Variant
Dim strBody As String
Dim intIn As Long
Dim intAttachCount As Integer, intStandardAttachCount As Integer
On Error GoTo handleError
‘Edit the following line if you have a signature on your email that includes images or other files. Make intStandardAttachCount equal the number of files in your signature.
intStandardAttachCount = 0
strBody = LCase(Item.Body)
intIn = InStr(1, strBody, “original message”)
If intIn = 0 Then intIn = Len(strBody)
intIn = InStr(1, Left(strBody, intIn), “attachment”)
intAttachCount = Item.Attachments.Count
If intIn > 0 And intAttachCount <= intStandardAttachCount Then
m = MsgBox(“It appears that you mean to send an attachment,” & vbCrLf & “but there is no attachment to this message.” & vbCrLf & vbCrLf & “Do you still want to send?”, vbQuestion + vbYesNo + vbMsgBoxSetForeground)
If m = vbNo Then Cancel = True
End If
handleError:
If Err.Number <> 0 Then
MsgBox “Outlook Attachment Reminder Error: ” & Err.Description, vbExclamation, “Outlook Attachment Reminder Error”
End If
这是您前段时间想要的。
intIn = InStr(1, strBody, “original message”)
If intIn = 0 Then intIn = Len(strBody)
intIn = InStr(1, Left(strBody, intIn), “attachment”)
文本"原始消息"不再用于区分新旧消息。
新的分隔符是"From:"
intIn = InStr(1, strBody, “From: ”)