Recipients email address

V

VebKol

Hi

I have problems reading email address from all recipients on my current
mail, it is no problem to get the names for all the recipients, but... email
adress......

I'm using the following code to get names, but need som tip's on how to get
the mail address for this persons...

I'm using Redemtion :)

----------------------------------------------------------------------------------------
Set Application = CreateObject("Outlook.Application")
Set sInspector = CreateObject("Redemption.SafeInspector")
sInspector.Item = Application.ActiveInspector

NoPers = sInspector.CurrentItem.Recipients.Count
For t = 1 To NoPers
Select Case sInspector.CurrentItem.Recipients.Item(t).Type
Case 1
Debug.Print "to=" &
myinspector.CurrentItem.Recipients.Item(t)
Case 2
Debug.Print "cc=" &
myinspector.CurrentItem.Recipients.Item(t)
End Select
Next t
 
D

Dmitry Streblechenko

Recipient.Item(index) returns a Recipient object, which exposes a few
properties, such as Name, Address, Type, etc. Your code reads only the
default Recipient object property, which happens to be Name.
Use
myinspector.CurrentItem.Recipients.Item(t).Address

As a side note, multiple dot notation is bad. Cache both the Recipients
colleciton and the Recipient object.
SEcondly, you are emoving drecipients in the loop, which decreases the
number of items in teh colleciton.
Loop from Count down do to 1 (step - 1) instead.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
V

VebKol

Point taken :),
but how do I resolve this mail address :

/O=NET/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=PETER.PAN


--
Regards
OD


Dmitry Streblechenko said:
Recipient.Item(index) returns a Recipient object, which exposes a few
properties, such as Name, Address, Type, etc. Your code reads only the
default Recipient object property, which happens to be Name.
Use
myinspector.CurrentItem.Recipients.Item(t).Address

As a side note, multiple dot notation is bad. Cache both the Recipients
colleciton and the Recipient object.
SEcondly, you are emoving drecipients in the loop, which decreases the
number of items in teh colleciton.
Loop from Count down do to 1 (step - 1) instead.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
K

Ken Slovak - [MVP - Outlook]

Recipient.AddressEntry.SmtpAddress, bearing in mind Dmitry's warning about
using compound dot operators. You'd need a SafeRecipient or RDORecipient
object for that though, the Outlook AddressEntry object doesn't have an
SmtpAddress property.
 
V

VebKol

I'm not that skilled....

Do you have any example code ?


--
Regards
OD


Ken Slovak - said:
Recipient.AddressEntry.SmtpAddress, bearing in mind Dmitry's warning about
using compound dot operators. You'd need a SafeRecipient or RDORecipient
object for that though, the Outlook AddressEntry object doesn't have an
SmtpAddress property.
 
K

Ken Slovak - [MVP - Outlook]

If the item in the Inspector is a mail item then something like this:

Dim oMail As Outlook.MailItem
Dim rMail As Redemption.SafeMailItem
Dim rRecips As Redemption.SafeRecipients
Dim rRecip As Redemption.SafeRecipient
Dim rAE As Redemption.SafeAddressEntry
Dim sAddy As String

Set oMail = Inspector.CurrentItem
Set rMail = CreateObject("Redemption.SafeMailItem")
rMail.Item = oMail
Set rRecips = rMail.Recipients
Set rRecip = rRecips.Item(1)
Set rAE = rRecip.AddressEntry
sAddy = rAE.SmtpAddress
MsgBox sAddy
 
V

VebKol

Sorry, but I get a error when compiling/running this :

at this line :
Dim rAE As Redemption.SafeAddressEntry

Error : User-defined type not defined

You know why ?
--
Regards
OD


Ken Slovak - said:
If the item in the Inspector is a mail item then something like this:

Dim oMail As Outlook.MailItem
Dim rMail As Redemption.SafeMailItem
Dim rRecips As Redemption.SafeRecipients
Dim rRecip As Redemption.SafeRecipient
Dim rAE As Redemption.SafeAddressEntry
Dim sAddy As String

Set oMail = Inspector.CurrentItem
Set rMail = CreateObject("Redemption.SafeMailItem")
rMail.Item = oMail
Set rRecips = rMail.Recipients
Set rRecip = rRecips.Item(1)
Set rAE = rRecip.AddressEntry
sAddy = rAE.SmtpAddress
MsgBox sAddy
 
K

Ken Slovak - [MVP - Outlook]

Because it should have been Dim rAE As Redemption.AddressEntry.

It just goes to show that I shouldn't write code off the top of my head, and
that you should look at the Object Browser :)
 
V

VebKol

Thank you very much !
I'ts working now !!!

it is extreamly good to have this kind of feedback from persons like you :)


But now I faced a new problem :-( .....

ref : Reading SMTP address from Exchange Sender mail address
...... reading SMPT address form sender e-mail..

--
Regards
OD


Ken Slovak - said:
Because it should have been Dim rAE As Redemption.AddressEntry.

It just goes to show that I shouldn't write code off the top of my head, and
that you should look at the Object Browser :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top