static string GetMailItemHeaders( Outlook.MailItem item )
{
const string PR_TRANSPORT_MESSAGE_HEADERS =
"
http://schemas.microsoft.com/mapi/proptag/0x007D001E";
Outlook.PropertyAccessor oPropAccessor = item.PropertyAccessor;
string headers = (string)oPropAccessor.GetProperty(
PR_TRANSPORT_MESSAGE_HEADERS );
return headers;
}
void JunkItems_ItemAdd( object Item )
{
try
{
if ( !(Item is Outlook.MailItem) )
return;
Outlook.MailItem mailItem = (Outlook.MailItem)Item;
if ( !mailItem.UnRead )
return;
string headers = GetMailItemHeaders( mailItem );
if ( headers.Contains( "X-Spam-Flag: YES" ) )
{
mailItem.UnRead = false;
}
}
catch
{
}
}
What approach did you take? I was thinking it might be useful to use
ItemsAdd on the Junk E-mail folder to run all the rules on demand.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers