hello, I have an event sink that traps mail going through the smtp
server.

I need to parse the msg.to field so that I can get each single user:
the string looks like this:

"Johnny Lance (BCO-London)" <jlance@bco.net>, "lhughes@bco.net"
<lhughes@bco.net>

basically I need to get the smtp address of each recipient, the one
between the "<" and ">". The recipents could be just one or a few. So
I would need to cycle through this list but honestly I have no idea
how build this array in a vbscript.

Anybody can give a hand ? It would be much appreciated.

Thanks in advance.
Regards,
zz

Re: problem parsing recipients from email to field by Tom

Tom
Tue Jan 29 09:24:00 CST 2008

On Jan 29, 9:31 am, zerbi...@gmail.com wrote:
> hello, I have an event sink that traps mail going through the smtp
> server.
>
> I need to parse the msg.to field so that I can get each single user:
> the string looks like this:
>
> "Johnny Lance (BCO-London)" <jla...@bco.net>, "lhug...@bco.net"
> <lhug...@bco.net>
>
> basically I need to get the smtp address of each recipient, the one
> between the "<" and ">". The recipents could be just one or a few. So
> I would need to cycle through this list but honestly I have no idea
> how build this array in a vbscript.
>
> Anybody can give a hand ? It would be much appreciated.
>
> Thanks in advance.
> Regards,
> zz

If the strings are always formatted as you show them in a variable
named sMsg_To, this snippet of code is one way ...

aAddr = Split(Replace(sMsg_To, ">", ""), ",")
For i = 0 to Ubound(aAddr)
aAddr(i) = Split(aAddr(i), "<")(1)
Next

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/

Re: problem parsing recipients from email to field by Anthony

Anthony
Tue Jan 29 16:14:31 CST 2008

<zerbie45@gmail.com> wrote in message
news:832eb222-7315-4085-8a7f-66c695d74666@e4g2000hsg.googlegroups.com...
> hello, I have an event sink that traps mail going through the smtp
> server.
>
> I need to parse the msg.to field so that I can get each single user:
> the string looks like this:
>
> "Johnny Lance (BCO-London)" <jlance@bco.net>, "lhughes@bco.net"
> <lhughes@bco.net>
>
> basically I need to get the smtp address of each recipient, the one
> between the "<" and ">". The recipents could be just one or a few. So
> I would need to cycle through this list but honestly I have no idea
> how build this array in a vbscript.
>
> Anybody can give a hand ? It would be much appreciated.
>

Note that if you're only interested in the email recipients (Whether To, CC
or even BCC) whose post boxes are in the mail domain managed the by server
you can retrieve these via the EnvelopeFields property of the msg.

Const cdoRecipientList =
"http://schemas.microsoft.com/cdo/smtpenvelope/recipientlist"


sRecipientList = Msg.EnvelopeFields.Item(cdoRecipientList).Value

It will have the format:-

SMTP:jlance@bco.net; SMTP:lhughes@bco.net;

(assuming the SMTP server whose events you are sinking is handled the
bco.net mail domain).


--
Anthony Jones - MVP ASP/ASP.NET