本文介绍了Vba代码检查我在代码中给出的电子邮件ID集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
我有一组电子邮件地址用于那些电子邮件地址我不应该发送任何邮件,即使我在收件人字段中输入邮件在新邮件中,当我点击发送密钥时,它通过弹出如XXXX邮件ID匹配在联系人列表中我在代码中提到它。
任何人都可以请提供代码来检查TO字段中的邮件ID和代码。
i尝试下面的代码。
Hello,
I have a set of email address for those email address i should not send any mails even though if i enter their mail in "To" field in new mail when i click send key it through a pop up like XXXX mail id is matched in do not contact list which i mentioned it in code.
can anyone please provide me the code to check mail id in the "TO" field and the code.
i tried the below code.
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim Recipients As Outlook.Recipients
Dim recip As Outlook.Recipient
Dim i
Dim prompt As String
On Error Resume Next
' use lower case for the address
' LCase converts all addresses in the To field to lower case
Set Recipients = Item.Recipients
For i = Recipients.Count To 1 Step -1
Set recip = Recipients.Item(i)
If InStr(LCase(recip), "[email protected]") Then
prompt$ = "You sending this to this to " & Item.To & ". Are you sure you want to send it?"
If MsgBox(prompt$, vbYesNo + vbQuestion + vbMsgBoxSetForeground, "Check Address") = vbNo Then
Cancel = True
End If
End If
Next i
End Sub
问候
Pradeep
Regards
Pradeep
推荐答案
问候
Pradeep
Regards
Pradeep
这篇关于Vba代码检查我在代码中给出的电子邮件ID集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!