![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
Ads |
#2
|
|||
|
|||
![]()
If you wanted to handle this, you'd need to write a VBA macro to trap the
ItemAdd event for the Inbox folder that is referenced by a MAPIFolder object whose Items collection has been globally declared using With Events in the ThisOutlookSession module, and set during the Application_Startup event. However, Outlook will need to be running all the time, and the ItemAdd is not *guaranteed* to fire if many messages are delivered/copied/moved at once (usually greater than 16). If you need a perfect solution that will run on the server side and does not require Outlook to be running, and that is guaranteed to fire on all incoming mail, you have to write an Exchange Event Sink. For more info on that, see: Microsoft Exchange Server Development Technologies: http://www.outlookcode.com/d/exstech.htm You can also ping me offline, as I know event sinks very well. I've included the starter code below to start you on your path. All you need to do is add the code to check the sender’s e-mail address against another list and move it to your spam folder if it matches. Option Explicit Dim WithEvents NewMailItems As Outlook.Items Private Sub Application_Startup() Set NewMailItems = Application.GetNamespace("MAPI").GetDefaultFolder( olFolderInbox).Items End Sub Private Sub NewMailItems_ItemAdd(ByVal Item As Object) 'THIS WILL FIRE FOR EVERY NEW E-MAIL; YOU CAN USE THE 'Item OBJECT TO WORK WITH THE PROPERTIES OF THE E-MAIL MESSAGE Dim objMail As Outlook.MailItem If Item.Class olmail Then Exit Sub Set objMail = Item 'Now you can do someting with the e-mail End Sub Private Sub Application_Quit() Set NewMailItems = Nothing End Sub -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "Veerle" wrote: Hi, I would like to create a rule in outlook that moves all the incoming emails (or emails in my inbox) for which the receiver's emailaddress is not in a certain list to the spam folder. This is because we have a domainname veerle-en-koen.be, but only use like 4 emailaddress of this domainname and we get lots of spam to the other emailaddresses of this domain like , , ... The reason is that the company where we registered our domainname forwards all the mail of the domain. So I would like to check the receiver(s) of the incoming mails to see if one of our 4 really used emailaddresses are in it, and if not: move the mail to the spam folder. But I don't think this is possible with the rules of outlook. So now the real question: I could write something in VBA that does this check, but how can I make sure this VBA script is automaticcaly executed each time new email arrives? If I could get an extra button on one of the outlook toolbars that executes the script when pressed and parses all the emails in the inbox would be fine as well, is that possible? Veerle |
#3
|
|||
|
|||
![]()
I guess it seems that it depends on the version.
I've written at Outlook 2003 on event NewMail, that adds a user field to each new mail which holds the receiving date. But with Outlook 2007 it does not work anymore. I even tried it with ItemAdd but both fails in the case you've rules that moves the new e-mails in other folders. It seems that Outlook 2007 now first handles the rules before the events of the inbox folder can be fired. :-( Outlook 2003 first fired the event and then executed the rules. Sighing greetings Reiner Eric Legault [MVP - Outlook] erklärte : If you wanted to handle this, you'd need to write a VBA macro to trap the ItemAdd event for the Inbox folder that is referenced by a MAPIFolder object whose Items collection has been globally declared using With Events in the ThisOutlookSession module, and set during the Application_Startup event. However, Outlook will need to be running all the time, and the ItemAdd is not *guaranteed* to fire if many messages are delivered/copied/moved at once (usually greater than 16). If you need a perfect solution that will run on the server side and does not require Outlook to be running, and that is guaranteed to fire on all incoming mail, you have to write an Exchange Event Sink. For more info on that, see: Microsoft Exchange Server Development Technologies: http://www.outlookcode.com/d/exstech.htm You can also ping me offline, as I know event sinks very well. I've included the starter code below to start you on your path. All you need to do is add the code to check the sender’s e-mail address against another list and move it to your spam folder if it matches. Option Explicit Dim WithEvents NewMailItems As Outlook.Items Private Sub Application_Startup() Set NewMailItems = Application.GetNamespace("MAPI").GetDefaultFolder( olFolderInbox).Items End Sub Private Sub NewMailItems_ItemAdd(ByVal Item As Object) 'THIS WILL FIRE FOR EVERY NEW E-MAIL; YOU CAN USE THE 'Item OBJECT TO WORK WITH THE PROPERTIES OF THE E-MAIL MESSAGE Dim objMail As Outlook.MailItem If Item.Class olmail Then Exit Sub Set objMail = Item 'Now you can do someting with the e-mail End Sub Private Sub Application_Quit() Set NewMailItems = Nothing End Sub -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "Veerle" wrote: Hi, I would like to create a rule in outlook that moves all the incoming emails (or emails in my inbox) for which the receiver's emailaddress is not in a certain list to the spam folder. This is because we have a domainname veerle-en-koen.be, but only use like 4 emailaddress of this domainname and we get lots of spam to the other emailaddresses of this domain like , , ... The reason is that the company where we registered our domainname forwards all the mail of the domain. So I would like to check the receiver(s) of the incoming mails to see if one of our 4 really used emailaddresses are in it, and if not: move the mail to the spam folder. But I don't think this is possible with the rules of outlook. So now the real question: I could write something in VBA that does this check, but how can I make sure this VBA script is automaticcaly executed each time new email arrives? If I could get an extra button on one of the outlook toolbars that executes the script when pressed and parses all the emails in the inbox would be fine as well, is that possible? Veerle -- Reiner -- "Wer fragt, ist ein Narr für fünf Minuten. Wer nicht fragt, bleibt ein Narr für immer." Chinesische Weisheit "Erfolg hat, wer ihm entgegengeht, statt ihm nachzulaufen." Onassis, Aristoteles |
#4
|
|||
|
|||
![]()
It has never been documented who wins between NewMail events and Outlook
rules, nor should you rely on either to occur in a determined order - for *all* Outlook versions. If you want to win this battle you need to create an Exchange Event Sink, which always fires first. -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "Reiner Block" wrote: I guess it seems that it depends on the version. I've written at Outlook 2003 on event NewMail, that adds a user field to each new mail which holds the receiving date. But with Outlook 2007 it does not work anymore. I even tried it with ItemAdd but both fails in the case you've rules that moves the new e-mails in other folders. It seems that Outlook 2007 now first handles the rules before the events of the inbox folder can be fired. :-( Outlook 2003 first fired the event and then executed the rules. Sighing greetings Reiner Eric Legault [MVP - Outlook] erklärte : If you wanted to handle this, you'd need to write a VBA macro to trap the ItemAdd event for the Inbox folder that is referenced by a MAPIFolder object whose Items collection has been globally declared using With Events in the ThisOutlookSession module, and set during the Application_Startup event. However, Outlook will need to be running all the time, and the ItemAdd is not *guaranteed* to fire if many messages are delivered/copied/moved at once (usually greater than 16). If you need a perfect solution that will run on the server side and does not require Outlook to be running, and that is guaranteed to fire on all incoming mail, you have to write an Exchange Event Sink. For more info on that, see: Microsoft Exchange Server Development Technologies: http://www.outlookcode.com/d/exstech.htm You can also ping me offline, as I know event sinks very well. I've included the starter code below to start you on your path. All you need to do is add the code to check the sender’s e-mail address against another list and move it to your spam folder if it matches. Option Explicit Dim WithEvents NewMailItems As Outlook.Items Private Sub Application_Startup() Set NewMailItems = Application.GetNamespace("MAPI").GetDefaultFolder( olFolderInbox).Items End Sub Private Sub NewMailItems_ItemAdd(ByVal Item As Object) 'THIS WILL FIRE FOR EVERY NEW E-MAIL; YOU CAN USE THE 'Item OBJECT TO WORK WITH THE PROPERTIES OF THE E-MAIL MESSAGE Dim objMail As Outlook.MailItem If Item.Class olmail Then Exit Sub Set objMail = Item 'Now you can do someting with the e-mail End Sub Private Sub Application_Quit() Set NewMailItems = Nothing End Sub -- Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration) Try Picture Attachments Wizard for Outlook: http://www.collaborativeinnovations.ca Blog: http://blogs.officezealot.com/legault/ "Veerle" wrote: Hi, I would like to create a rule in outlook that moves all the incoming emails (or emails in my inbox) for which the receiver's emailaddress is not in a certain list to the spam folder. This is because we have a domainname veerle-en-koen.be, but only use like 4 emailaddress of this domainname and we get lots of spam to the other emailaddresses of this domain like , , ... The reason is that the company where we registered our domainname forwards all the mail of the domain. So I would like to check the receiver(s) of the incoming mails to see if one of our 4 really used emailaddresses are in it, and if not: move the mail to the spam folder. But I don't think this is possible with the rules of outlook. So now the real question: I could write something in VBA that does this check, but how can I make sure this VBA script is automaticcaly executed each time new email arrives? If I could get an extra button on one of the outlook toolbars that executes the script when pressed and parses all the emails in the inbox would be fine as well, is that possible? Veerle -- Reiner -- "Wer fragt, ist ein Narr für fünf Minuten. Wer nicht fragt, bleibt ein Narr für immer." Chinesische Weisheit "Erfolg hat, wer ihm entgegengeht, statt ihm nachzulaufen." Onassis, Aristoteles |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to check emails whilst out of the office? | abbyT | Outlook - General Queries | 2 | January 23rd 07 01:40 PM |
OE will not retrieve incoming emails | Widener U | Outlook Express | 4 | September 12th 06 12:35 PM |
Not receiving any incoming emails | Godz Lady | Outlook - General Queries | 3 | September 12th 06 01:35 AM |
Graphics in incoming emails are suppressed | Big Al-Bob | Outlook Express | 2 | July 15th 06 10:35 PM |
how to disable security check for incoming signed mails | Cagdas Ozgenc | Outlook - General Queries | 0 | April 20th 06 07:06 AM |