Outlook 2010 VBA script help

cuemasterfl

Supreme [H]ardness
Joined
Jul 5, 2001
Messages
4,181
I didn't see how I could do this using the rules functions that Outlook provides, so I'm turning to VBA to achieve what I need.

I basically need Outlook to look at each incoming message, and if it's from an approved Domain (of which there about 10), let it go into the Inbox. If the message is not from an approved domain, send them a reply saying their email will not be accepted (etc), and then delete it.

I've Googled this, but can't find a solution. Thank you in advance.
 
I basically need Outlook to look at each incoming message, and if it's from an approved Domain (of which there about 10), let it go into the Inbox. If the message is not from an approved domain, send them a reply saying their email will not be accepted (etc), and then delete it.
Found this StackOverflow thread that goes over setting up a listener that gets loaded on app startup, and even shows where you would implement your custom business rule.

However, your goal sounds like something better handled at the mail server instead of in a desktop client app.
 
Thank you PTNL. I'll play with this, but I have no idea what code to add. I imagined being able to add something like Msg.SenderEmailAddress.Contains ("@mydomain.org") to see if the sender's email address contained a particular domain, but it didn't like that.
 
Oh and I did at first suggest that this be done on the server, but the System Admin wanted me to do it locally.
 
Thank you PTNL. I'll play with this, but I have no idea what code to add. I imagined being able to add something like Msg.SenderEmailAddress.Contains ("@mydomain.org") to see if the sender's email address contained a particular domain, but it didn't like that.
The Intellisense in the VBA code area is not the greatest. Best bet is to logically figure out the individual steps, and try your Google-fu at each piece; or, to shortcut the approach, just do the individual searches in StackOverflow :)

Oh and I did at first suggest that this be done on the server, but the System Admin wanted me to do it locally.
Overall, that decision sounds crazy; however, I am curious about the rationale behind the SysAdmin's decision.

Definitely document this one-off implementation.
 
Last edited:
I've almost got it working, but I won't be back in the office until Friday ;) I'll update this when I get it working. I could play with it at home tonight, but I'm not in the mood :)
 
Back
Top