Does redemption require user to be logged on?

D

dcook23

I have created a script that uses SMTP to send an email off a
designated server and then uses redemption to check if the message has
arrived in the specified mailbox. The script is being automatically
kicked off by a monitoring product and running under an account that
has an Outlook profile setup. The script works great if the account is
logged on to the machine no matter if Outlook is already open or not.
If the account is not logged on then the script will not continue
beyond the line below.

set Inbox = Session.GetDefaultFolder(olFolderInbox)

I have tried to trap an error message but nothing after the line above
is executed but the script exits. My question is does redemption
require the user account be logged in?

The full piece of my code that is using redemption is below.
Const olFolderInbox = 6
set Session = CreateObject("Redemption.RDOSession")
Session.Logon

set Inbox = Session.GetDefaultFolder(olFolderInbox)
for each Msg in Inbox.Items
for each att in msg.Attachments
If lcase(left(att.filename,4)) = "fax-" Then
If DateDiff("n",msg.ReceivedTime,FaxSentTime) <
5 Then
vSuccess = "yes"
End If
End If
Next
msg.delete
Next
 
K

Ken Slovak - [MVP - Outlook]

RDOSession does require a logon or an assignment of MAPIOBJECT. I would
check for Session.LoggedOn after the Logon call to verify that the session
is truly logged on.
 
D

Dmitry Streblechenko

Do you mean whether it makes any difference which Windows user identity your
code is running under? Of course, RDOSession.Logon will try to log to the
default profile, which clearly depends on who the user is. It is possible
that the current user (e.g. local service account) does not have any
profiles at all. Or (if you are impersonating a user), the HKCU registry
hive (where the profile are stored) for that user are not loaded.

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

dcook23

Thank you for the reply.

The monitoring product that executing the script is executing it using
a run as so it is running using the credentials of the account that has
the Outlook profile configured. Is this not enough to load the hive
where the profile is stored?

Would using the MAPIOBJECT make any difference?
 
D

Dmitry Streblechenko

Did you try to specify an explicit profile name when calling
RDOSession.Logon? How did you trap the error?

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

dcook23

I tried specifying the profile name and I get the same results.

I have also tried trapping an error with no luck. I setup the script to
create a log file when it runs. The logon code looks like this to do my
logging:

' Use redemption to logon to default MAPI profile
set Session = CreateObject("Redemption.RDOSession")
objFile.writeline "going to logon"
Session.Logon
ObjFile.writeline "post logon"
objFile.writeline session.loggedon

If I have the user account logged into the server when the monitoring
product kicks off the script I get the following written to my log:

going to logon
post logon
True

If the user account is not logged onto the machine when the script
kicks off I get only the line that says "going to logon" and nothing
more. I have also tried using "On Error Resume Next" before the logon
even and then writing err.number immediately after logon. That results
in 0 when the account is logged on and nothing is writen after "going
to logon" when the account is not logged on. It appears the script
exits at the "Session.Logon" if the account is not logged on.

Does this make sense? Does anyone know if I should be able to get this
to work without having the account logged in?

I very much appreciate the help.
 
D

dcook23

It is an Exchange mailbox. I initially tried the LogonExchangeMailbox
method but that was failing on the GetDefaultFolder so I thought maybe
I had to use a different method for that method to work.
 
D

Dmitry Streblechenko

Contact me at my private e-mail address - I'll send you a debug version that
creates a log file.

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