Outlook – check email address type
I am trying to make a macro in Outlook that will scan the To: list for a certain text string, and spit out a message if all but one (or two, etc) addresses have it. Is there a simple way to do this?
Essentially, I am trying to write something that'll avoid being able to send a restricted message to a bunch of people with the string 'xyz' in the address, if one or more do not have it. AutoComplete makes this difficult, without checking through one-by-one.
如果你对这篇文章有疑问,欢迎到本站 社区 发帖提问或使用手Q扫描下方二维码加群参与讨论,获取更多帮助。

评论(1)

This is possible using Outlook VBA.
You'd have to write an event hook for when the user sends an email. This is done using the Application_ItemSend(ByVal Item As Object, Cancel As Boolean) where Item is the item being sent (email or appointment), and cancel is a boolean you can set to stop the email from being sent.
In your code you would want to look at the recipients collection on the Item object to see who is going to be receiving the email.
For example:
Dim CurrRecip As Recipient
For Each CurrRecip in Item.Recipients
If InStr(1, CurrRecip.Address , "your search text here" , vbCompareText ) Then
debug.print "Message here..."
End If
Next CurrRecip
Hopefully that helps...
发布评论
需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。