Home All Groups Group Topic Archive Search About

Repost: Comparing Senders with Contacts

Author
23 Oct 2007 2:50 PM
Patrick Pirtle
I've written an app that redirects incoming emails to
different folders based upon categories assigned in
my contacts.  I use the lines:

    strAddress = oSafeMail.Sender.Address
    For i = 1 To 3
        strFind = "[Email" & i & "Address] = """ & strAddress & """ and
[FileAs] <> ""Group"""
        Set oContact = allContacts.Find(strFind)

to loop through my contacts looking for the sender.

My problem is that, on occasion, this fails to find the
person in my contacts even though they're in there.
When I start trying to debug the problem, I start
getting confused as to just what is being compared.



For example,   I might have a contact with:

    Email... = SJohn***@company.com"
    Display as: "Susan M.Johnson P.E. (SJohn***@company.com)"

I receive an email from her, and it displays in my inbox
as being from "Susan M. Johnson".  If I open the email,
the From field contains "Susan M. Johnson".  If I
try to look at the header through the View\Options menu,
it doesn't show any header at all, as this came through
the Exchange Server.

The search string my app builds looks like:
"[Email1Address] = "/O=COMPANY/OU=FIRST ADMINISTRATIVE
GROUP/CN=RECIPIENTS/CN=SMJ" and [FileAs] <> "Group""

I assume the "SMJ" above is because her email is
actually stored as S**@company.com and Exchange
has "Susan M. Johnson" as some kind of alias.(?)

My app correctly moves this one to the correct folder.




Now, I have another contact with:

    Email... = "RJo***@hotmail.com"
    Display as: "RJo***@hotmail.com"

I receive an email from him, and it displays in my inbox
as being from "Rick Jones".  If I open the email email, the
From field contains "Rick Jones [rjo***@hotmail.com]".
If I look at the header through the View\Options menu,
it shows it to be from "Rick Jones <rjo***@hotmail.com>".

The search string my app builds looks like:

"[Email1Address] = RJo***@hotmail.com and [FileAs] <> "Group""

My app correctly moves this one to the correct folder.




And finally, I have a contact with:

    Email... = "PSm***@company.com"
    Display as: "Paul A Smith P.E. (PSm***@company.com)"

I receive an email from him VIA BLACKBERRY, and it
displays in my inbox as being from "Paul Smith".  If I open
the email, the From field contains "Paul Smith [PSm***@company.com]".
If I try to look at the header through the View\Options menu,
it shows it to be from:

"=?utf-8?B?QnJhZCBDYW1lcm9u?=" <PSm***@company.com>"

The search string it is building looks like:

"[Email1Address] = PSm***@company.com and [FileAs] <> "Group""

My app FAILS to find this person in my contacts.




I've tried modifying my contact's "Email...", "Display as:",
etc. every which way I could, but can't quite figure out what
is really being compared.  Is there a better way to search
for these?  TIA for any help and suggestions.
____________________________________________
The impossible just takes a little longer...

Author
23 Oct 2007 3:13 PM
Ken Slovak - [MVP - Outlook]
This looks like it's using Redemption code, is that true?

If so why not use oSafeMail.Sender.SmtpAddress instead? That will always
return an SMTP address even if the sender has an Exchange distinguished name
as their email address and it avoids the displayname problem.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


Show quote
"Patrick Pirtle mka com>" <pap <atdot> wrote in message
news:%23kxeUQYFIHA.1184@TK2MSFTNGP04.phx.gbl...
> I've written an app that redirects incoming emails to
> different folders based upon categories assigned in
> my contacts.  I use the lines:
>
>    strAddress = oSafeMail.Sender.Address
>    For i = 1 To 3
>        strFind = "[Email" & i & "Address] = """ & strAddress & """ and
> [FileAs] <> ""Group"""
>        Set oContact = allContacts.Find(strFind)
>
> to loop through my contacts looking for the sender.
>
> My problem is that, on occasion, this fails to find the
> person in my contacts even though they're in there.
> When I start trying to debug the problem, I start
> getting confused as to just what is being compared.
>
>
>
> For example,   I might have a contact with:
>
>    Email... = SJohn***@company.com"
>    Display as: "Susan M.Johnson P.E. (SJohn***@company.com)"
>
> I receive an email from her, and it displays in my inbox
> as being from "Susan M. Johnson".  If I open the email,
> the From field contains "Susan M. Johnson".  If I
> try to look at the header through the View\Options menu,
> it doesn't show any header at all, as this came through
> the Exchange Server.
>
> The search string my app builds looks like:
> "[Email1Address] = "/O=COMPANY/OU=FIRST ADMINISTRATIVE
> GROUP/CN=RECIPIENTS/CN=SMJ" and [FileAs] <> "Group""
>
> I assume the "SMJ" above is because her email is
> actually stored as S**@company.com and Exchange
> has "Susan M. Johnson" as some kind of alias.(?)
>
> My app correctly moves this one to the correct folder.
>
>
>
>
> Now, I have another contact with:
>
>    Email... = "RJo***@hotmail.com"
>    Display as: "RJo***@hotmail.com"
>
> I receive an email from him, and it displays in my inbox
> as being from "Rick Jones".  If I open the email email, the
> From field contains "Rick Jones [rjo***@hotmail.com]".
> If I look at the header through the View\Options menu,
> it shows it to be from "Rick Jones <rjo***@hotmail.com>".
>
> The search string my app builds looks like:
>
> "[Email1Address] = RJo***@hotmail.com and [FileAs] <> "Group""
>
> My app correctly moves this one to the correct folder.
>
>
>
>
> And finally, I have a contact with:
>
>    Email... = "PSm***@company.com"
>    Display as: "Paul A Smith P.E. (PSm***@company.com)"
>
> I receive an email from him VIA BLACKBERRY, and it
> displays in my inbox as being from "Paul Smith".  If I open
> the email, the From field contains "Paul Smith [PSm***@company.com]".
> If I try to look at the header through the View\Options menu,
> it shows it to be from:
>
> "=?utf-8?B?QnJhZCBDYW1lcm9u?=" <PSm***@company.com>"
>
> The search string it is building looks like:
>
> "[Email1Address] = PSm***@company.com and [FileAs] <> "Group""
>
> My app FAILS to find this person in my contacts.
>
>
>
>
> I've tried modifying my contact's "Email...", "Display as:",
> etc. every which way I could, but can't quite figure out what
> is really being compared.  Is there a better way to search
> for these?  TIA for any help and suggestions.
> ____________________________________________
> The impossible just takes a little longer...
>
Author
5 Nov 2007 3:53 PM
Patrick Pirtle
Ken -
Yes, I *am* using Redemption.  Many thanks for the
suggestion.  I'll give that a try today.

- Patrick


Ken Slovak - [MVP - Outlook] wrote:
> This looks like it's using Redemption code, is that true?
>
> If so why not use oSafeMail.Sender.SmtpAddress instead? That will
> always return an SMTP address even if the sender has an Exchange
> distinguished name as their email address and it avoids the
> displayname problem.

[snip]
Author
5 Nov 2007 11:46 PM
Patrick Pirtle
____________________________________________
The impossible just takes a little longer...Ken Slovak - [MVP - Outlook]
wrote:
Show quote
> This looks like it's using Redemption code, is that true?
>
> If so why not use oSafeMail.Sender.SmtpAddress instead? That will
> always return an SMTP address even if the sender has an Exchange
> distinguished name as their email address and it avoids the
> displayname problem.
>
> "Patrick Pirtle mka com>" <pap <atdot> wrote in message
> news:%23kxeUQYFIHA.1184@TK2MSFTNGP04.phx.gbl...
>> I've written an app that redirects incoming emails to
>> different folders based upon categories assigned in
>> my contacts.  I use the lines:
>>
>>    strAddress = oSafeMail.Sender.Address
>>    For i = 1 To 3
>>        strFind = "[Email" & i & "Address] = """ & strAddress & """
>> and [FileAs] <> ""Group"""
>>        Set oContact = allContacts.Find(strFind)
>>
>> to loop through my contacts looking for the sender.
>>
>> My problem is that, on occasion, this fails to find the
>> person in my contacts even though they're in there.
>> When I start trying to debug the problem, I start
>> getting confused as to just what is being compared.
>>
>>
>>
>> For example,   I might have a contact with:
>>
>>    Email... = SJohn***@company.com"
>>    Display as: "Susan M.Johnson P.E. (SJohn***@company.com)"
>>
>> I receive an email from her, and it displays in my inbox
>> as being from "Susan M. Johnson".  If I open the email,
>> the From field contains "Susan M. Johnson".  If I
>> try to look at the header through the View\Options menu,
>> it doesn't show any header at all, as this came through
>> the Exchange Server.
>>
>> The search string my app builds looks like:
>> "[Email1Address] = "/O=COMPANY/OU=FIRST ADMINISTRATIVE
>> GROUP/CN=RECIPIENTS/CN=SMJ" and [FileAs] <> "Group""
>>
>> I assume the "SMJ" above is because her email is
>> actually stored as S**@company.com and Exchange
>> has "Susan M. Johnson" as some kind of alias.(?)
>>
>> My app correctly moves this one to the correct folder.
>>
>>
>>
>>
>> Now, I have another contact with:
>>
>>    Email... = "RJo***@hotmail.com"
>>    Display as: "RJo***@hotmail.com"
>>
>> I receive an email from him, and it displays in my inbox
>> as being from "Rick Jones".  If I open the email email, the
>> From field contains "Rick Jones [rjo***@hotmail.com]".
>> If I look at the header through the View\Options menu,
>> it shows it to be from "Rick Jones <rjo***@hotmail.com>".
>>
>> The search string my app builds looks like:
>>
>> "[Email1Address] = RJo***@hotmail.com and [FileAs] <> "Group""
>>
>> My app correctly moves this one to the correct folder.
>>
>>
>>
>>
>> And finally, I have a contact with:
>>
>>    Email... = "PSm***@company.com"
>>    Display as: "Paul A Smith P.E. (PSm***@company.com)"
>>
>> I receive an email from him VIA BLACKBERRY, and it
>> displays in my inbox as being from "Paul Smith".  If I open
>> the email, the From field contains "Paul Smith [PSm***@company.com]".
>> If I try to look at the header through the View\Options menu,
>> it shows it to be from:
>>
>> "=?utf-8?B?QnJhZCBDYW1lcm9u?=" <PSm***@company.com>"
>>
>> The search string it is building looks like:
>>
>> "[Email1Address] = PSm***@company.com and [FileAs] <> "Group""
>>
>> My app FAILS to find this person in my contacts.
>>
>>
>>
>>
>> I've tried modifying my contact's "Email...", "Display as:",
>> etc. every which way I could, but can't quite figure out what
>> is really being compared.  Is there a better way to search
>> for these?  TIA for any help and suggestions.
>> ____________________________________________
>> The impossible just takes a little longer...

--
Author
5 Nov 2007 11:57 PM
Patrick Pirtle
Well, it *looks* as though using the .SMTPAddress
should work just fine.  But, when I ran it, I could step
through the code and, although the SMTP address was
jsm***@mka.com, and I have a contact with
jsm***@mka.com in all three of the email addresses, it
fails to find it.

So, I guess that brings me around to my original questions.
What, exactly, is being compared?  Since the contacts are
being automatically deleted and refreshed from the
Exchange Server each night, could the email that's being
displayed in the three email addresses not be the email
that's *really* being compared?

Or, is there a better way to search the contacts?
____________________________________________
The impossible just takes a little longer...


Ken Slovak - [MVP - Outlook] wrote:
Show quote
> This looks like it's using Redemption code, is that true?
>
> If so why not use oSafeMail.Sender.SmtpAddress instead? That will
> always return an SMTP address even if the sender has an Exchange
> distinguished name as their email address and it avoids the
> displayname problem.
>
> "Patrick Pirtle mka com>" <pap <atdot> wrote in message
> news:%23kxeUQYFIHA.1184@TK2MSFTNGP04.phx.gbl...
>> I've written an app that redirects incoming emails to
>> different folders based upon categories assigned in
>> my contacts.  I use the lines:
>>
>>    strAddress = oSafeMail.Sender.Address
>>    For i = 1 To 3
>>        strFind = "[Email" & i & "Address] = """ & strAddress & """
>> and [FileAs] <> ""Group"""
>>        Set oContact = allContacts.Find(strFind)
>>
>> to loop through my contacts looking for the sender.
>>
>> My problem is that, on occasion, this fails to find the
>> person in my contacts even though they're in there.
>> When I start trying to debug the problem, I start
>> getting confused as to just what is being compared.
>>
>>
>>
>> For example,   I might have a contact with:
>>
>>    Email... = SJohn***@company.com"
>>    Display as: "Susan M.Johnson P.E. (SJohn***@company.com)"
>>
>> I receive an email from her, and it displays in my inbox
>> as being from "Susan M. Johnson".  If I open the email,
>> the From field contains "Susan M. Johnson".  If I
>> try to look at the header through the View\Options menu,
>> it doesn't show any header at all, as this came through
>> the Exchange Server.
>>
>> The search string my app builds looks like:
>> "[Email1Address] = "/O=COMPANY/OU=FIRST ADMINISTRATIVE
>> GROUP/CN=RECIPIENTS/CN=SMJ" and [FileAs] <> "Group""
>>
>> I assume the "SMJ" above is because her email is
>> actually stored as S**@company.com and Exchange
>> has "Susan M. Johnson" as some kind of alias.(?)
>>
>> My app correctly moves this one to the correct folder.
>>
>>
>>
>>
>> Now, I have another contact with:
>>
>>    Email... = "RJo***@hotmail.com"
>>    Display as: "RJo***@hotmail.com"
>>
>> I receive an email from him, and it displays in my inbox
>> as being from "Rick Jones".  If I open the email email, the
>> From field contains "Rick Jones [rjo***@hotmail.com]".
>> If I look at the header through the View\Options menu,
>> it shows it to be from "Rick Jones <rjo***@hotmail.com>".
>>
>> The search string my app builds looks like:
>>
>> "[Email1Address] = RJo***@hotmail.com and [FileAs] <> "Group""
>>
>> My app correctly moves this one to the correct folder.
>>
>>
>>
>>
>> And finally, I have a contact with:
>>
>>    Email... = "PSm***@company.com"
>>    Display as: "Paul A Smith P.E. (PSm***@company.com)"
>>
>> I receive an email from him VIA BLACKBERRY, and it
>> displays in my inbox as being from "Paul Smith".  If I open
>> the email, the From field contains "Paul Smith [PSm***@company.com]".
>> If I try to look at the header through the View\Options menu,
>> it shows it to be from:
>>
>> "=?utf-8?B?QnJhZCBDYW1lcm9u?=" <PSm***@company.com>"
>>
>> The search string it is building looks like:
>>
>> "[Email1Address] = PSm***@company.com and [FileAs] <> "Group""
>>
>> My app FAILS to find this person in my contacts.
>>
>>
>>
>>
>> I've tried modifying my contact's "Email...", "Display as:",
>> etc. every which way I could, but can't quite figure out what
>> is really being compared.  Is there a better way to search
>> for these?  TIA for any help and suggestions.
>> ____________________________________________
>> The impossible just takes a little longer...

--
____________________________________________
The impossible just takes a little longer...
Author
6 Nov 2007 1:56 PM
Ken Slovak - [MVP - Outlook]
I don't think the existing contacts are being deleted every night when an
offline address book is synched.

If the contact you are comparing has an Exchange DN as their email address
that's what it is, not the SMTP address. I think that's the problem. Again,
with Redemption there are better ways to do what you want. For example, why
not use a filtered MAPITable? You can set up the filter on all 3 email
addresses in a Contacts table and check things that way, which would allow
you to use complex Or's to compare the email addresses.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


Show quote
"Patrick Pirtle mka com>" <pap <atdot> wrote in message
news:%23kEYUeAIIHA.868@TK2MSFTNGP05.phx.gbl...
> Well, it *looks* as though using the .SMTPAddress
> should work just fine.  But, when I ran it, I could step
> through the code and, although the SMTP address was
> jsm***@mka.com, and I have a contact with
> jsm***@mka.com in all three of the email addresses, it
> fails to find it.
>
> So, I guess that brings me around to my original questions.
> What, exactly, is being compared?  Since the contacts are
> being automatically deleted and refreshed from the
> Exchange Server each night, could the email that's being
> displayed in the three email addresses not be the email
> that's *really* being compared?
>
> Or, is there a better way to search the contacts?
> ____________________________________________
> The impossible just takes a little longer...
Author
6 Nov 2007 3:27 PM
Patrick Pirtle
Ken -
In checking with our IS guys, it turns out the contacts
are not actually being sync'd with the Exchange Server.
They're running an in-house-written application each
night that deletes all of the contacts with certain
categories from each employee's contacts, and then
replaces the deleted contacts with updated contacts
from the central office database (which is part of some
marketing database separate from Exchange).

So...

I'm looking into Redemptions MAPITable explanation
now--it looks *very* promising.  As always, many thanks
for your help.
____________________________________________
The impossible just takes a little longer...


Ken Slovak - [MVP - Outlook] wrote:
Show quote
> I don't think the existing contacts are being deleted every night
> when an offline address book is synched.
>
> If the contact you are comparing has an Exchange DN as their email
> address that's what it is, not the SMTP address. I think that's the
> problem. Again, with Redemption there are better ways to do what you
> want. For example, why not use a filtered MAPITable? You can set up
> the filter on all 3 email addresses in a Contacts table and check
> things that way, which would allow you to use complex Or's to compare
> the email addresses.
[snip]

AddThis Social Bookmark Button