Vba代码检查我在代码中给出的电子邮件ID集 [英] Vba Code To Check Set Of Email Ids Which I Give In Code
本文介绍了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), "bad@address.com") 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
推荐答案
= 您将此发送给 &安培; Item。 To & 。您确定要发送吗?
If MsgBox(提示
= "You sending this to this to " & Item.To & ". Are you sure you want to send it?" If MsgBox(prompt
,vbYesNo + vbQuestion + vbMsgBoxSetForeground, 检查地址)= vbNo 然后
取消= 真
结束 如果
结束 如果
下一步 i
结束 Sub
, vbYesNo + vbQuestion + vbMsgBoxSetForeground, "Check Address") = vbNo Then Cancel = True End If End If Next i End Sub
问候
Pradeep
Regards
Pradeep
首先,您必须创建新的MailItem [ ^ ],然后你就可以发送电子邮件 [ ^ ]。但如果你想捕捉发送事件,那么你就是在正确的轨道上。遗憾的是,您没有提供有关请勿发送给这些收件人列表的足够信息:在何处以及如何定义。如果您想检查是否有任何收件人电子邮件地址等于 bad@address.com
,代码看起来很不错,但需要进行小的更改:获取收件人的电子邮件地址 [ ^ ]
First of all, you have to create new MailItem[^], then you'll be able to send an email[^]. But if you want to catch "sending" event, you're on the right track. Unfortunatelly, you did not provide enough information about "do-not-send-to-these-recipients" list: where and how it was defined. If you would like to check if any recipient email address is equal to "bad@address.com
", a code look pretty good, but needs small changes: Obtain the E-mail Address of a Recipient[^]
这篇关于Vba代码检查我在代码中给出的电子邮件ID集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文