Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vba Outlook 2010附件检查器宏-仅我编写的内容_Vba_Outlook_Attachment - Fatal编程技术网

Vba Outlook 2010附件检查器宏-仅我编写的内容

Vba Outlook 2010附件检查器宏-仅我编写的内容,vba,outlook,attachment,Vba,Outlook,Attachment,我一直在使用outlook 2010中的以下代码来提醒我添加附件,如果我在电子邮件中引用了附件而忘记附加任何内容。然而,我想知道是否有办法只检查我写的文本(而不检查我回复电子邮件时引用的文本)。由于我公司的安全设置,我无法添加外接程序,因此需要依赖VBA Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean) ‘ Pops up a reminder if the word “attach” is fou

我一直在使用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
私有子应用程序\u ItemSend(ByVal项作为对象,取消作为布尔值)
'如果找到“附件”一词,但您的电子邮件中没有附件,则会弹出提示。
Dim作为变体
像弦一样暗的链子
暗淡如长
Dim intAttachCount为整数,intStandardAttachCount为整数
关于错误转到handleError
'如果您的电子邮件上有包含图像或其他文件的签名,请编辑以下行。使intStandardAttachCount等于签名中的文件数。
intStandardAttachCount=0
strBody=LCase(项目正文)
intIn=InStr(1,字库,“原始信息”)
如果intIn=0,则intIn=Len(strBody)
intIn=仪表(1,左侧(底座,intIn),“附件”)
intAttachCount=Item.Attachments.Count

如果intIn>0且intAttachCount这在一段时间前就满足了您的要求

intIn = InStr(1, strBody, “original message”)

If intIn = 0 Then intIn = Len(strBody)

intIn = InStr(1, Left(strBody, intIn), “attachment”)
文本“原始消息”不再用于区分新旧消息

新的分隔符是“From”:


除非出于某种原因OP在文本的某个地方包含了字符串“from:”(这可能不太可能,但绝对不是不可能)。按照类似的推理思路,OP可以将Outlook配置为始终添加签名,然后执行
intIn=Instr(1,strBody,“您的名字在这里”)
。这既不是保证,尽管OP在邮件正文中包含自己全名的可能性似乎较小/漫无边际:)。
intIn = InStr(1, strBody, “From: ”)