inconsistent in Redemption

V

Vadivel

Hi,

I am trying to get the smtp address of the email item in outlook
offline(machine does not have outlook session). This is the my code.
But sometimes its giving the smtp address and sometimes it gives empty
stirng

Dim UtilObject As Redemption.MAPIUtils
Dim MessageItem As MessageItem
Dim ToAddress As SafeRecipient

Const PR_EMAIL = &H39FE001E

Set UtilObject = CreateObject("Redemption.MAPIUtils")

Set MessageItem = UtilObject.GetItemFromMsgFile("D:/test1.msg")

For Each ToAddress In MessageItem.Recipients

Debug.Print ToAddress.Address ' To get the smpt email id
If InStr(ToAddress.Address, "@") = 0 Then
Debug.Print ToAddress.Fields(PR_EMAIL) ' To get the smpt
email id
end if

Next

here ToAddress.Fields(PR_EMAIL) function sometiem gives proper smtp
address. but sometimes it gives empty string..

Any help really appreciated..

Thanks
Vadivel
 
K

Ken Slovak - [MVP - Outlook]

Dmitry can correct me if I'm wrong but I'd sort of expect inconsistent
results from MAPIUtils unless its MAPIOBJECT property was assigned from some
session's MAPIOBJECT property.

Can you log into Outlook and get the NameSpace to get its MAPIOBJECT?
Perhaps you can use Redemption's RDOSession object to log into a MAPI
session and then use that session's MAPIOBJECT?

I'd also use MAPIUtils.Cleanup at the end of the code to release the session
and clean things up.
 
D

Dmitry Streblechenko

PR_SMTP_ADDRESS is only available in the online mode. In the cached mode
(default in Outlook 2003) PR_SMTP_ADDRESS is ont available, so you need to
use PR_EMS_AB_PROXY_ADDRESSES instead (always available for the EX address
entries, see below).
Note that RDOAddressEntry object already exposes the SMTPAddress property.
Next version of Redemption will add that property to the
Redemption.AddressEntry object (returned by the Safe*Item objects).

PR_EMS_AB_PROXY_ADDRESSES = &H800F101E
If AddressEntry.Type = "EX" Then
ProxyAddresses = AddressEntry.Fields(PR_EMS_AB_PROXY_ADDRESSES)
for i = LBound(ProxyAddresses) to UBound(ProxyAddresses)
if Left(ProxyAddresses(i), 5) = "SMTP:" Then
strAddress = Right(ProxyAddresses(i), Len(ProxyAddresses(i))-5)
Exit for
End If
Next
End If


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

Vadivel

Dmitry Streblechenko,

If my machine has only outlook installed and never used it for
downloading email.. Will the above code work still?

Thanks
Vadivel
 
D

Dmitry Streblechenko

I am not sure I completely understand - do you mean you are reading MSG
files on a machine that might not have a MAPI profile set up to connect to
the Exchange server that used to host the message now saved as an MSG file?.
PR_SMTP_ADDRESS may or may not be available in the message recipients table.
If it is available, then Recipient.Fields(PR_SMTP_ADDRESS) will retrieve it.
If it is not available, the only workaround is to read the value of
PR_ENTRYID and call IAddrBook::OpenEntry - that's what reading
Recipient.AddressEntry would do. But that requires a MAPI session connected
to an EX server that will be able to open the entry id in question.

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

Vadivel

Dmitry Streblechenko,

My machine has only outlook installed and does not have mapi profile. I
trying to get the smtp addresses of the stored .msg files(i have stored
..msg file in the local hard disk.) I am using visual basic for that.
The above code is working for some email ids and it does not work for
some email ids. is there any way to solve this.

Thanks
Vadivel
 
D

Dmitry Streblechenko

Sorry, I am even more confused than before - how do you use Outlook if it
does not have at least one profile?
Where do the MSG files come from?

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

Dmitry Streblechenko

Do you mean by clicking "File | Save As" in Outlook? Or through some other
means?
Do you do that on the same machine? If yes, do you use the same MAPI profile
when saving and when restroring?

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

Vadivel

Hi,

All the emails (.msg files) stored in the FileNet document management
respository and i am getting it from FileNet repository and storing it
to local drive and parse the email. Now i am trying to get the email
ids of email.. So am not using mapi profile. I have just installed
outlook 2002 in my machine..

Thanks
Vadivel
 
D

Dmitry Streblechenko

You cannot use Outlook without a profile (unless it is Outlook 98/2000 in
the IMO mode, which has one predefeined profile).
If Outlook does not prompt you for the profile name, that does *not* mean
there is no profile.
What do you see when you go to Start|Control Panel|Mail|Show Profiles.
Is there an EX server in your default profile?

When you access Recipient.AddressEntry in Redemption is that it retrieves
PR_ENTRYID from the recipients and table and uses it to call
IAddrBook::OpenEntry.
In order to do that, it need IAddrBook, which comes from
IMAPISession::OpenAddrBook, hence it needs to have IMAPISession.
IMAPISession can come either from your explicitly setting
MAPIUtils.MAPIOBJECT to Namespace.MAPIOBJECT in OOM, or from logging to MAPI
and either retrieve teh currently running MAPI session (if Outlook is
already running) or by logging to the default MAPI profile.
After Redemption has IAddrBook, it will call IAddrBook:OpenEntry; and if the
entry id cannot be recognized in tehe current session, then
Reciouent.AddressEntry will return NULL.

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

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