Redemption program works fine in NT 4.0, fails in XP

  • Thread starter Mitchell Nussbaum
  • Start date
M

Mitchell Nussbaum

I wrote and maintain a fairly simple VB6 application that generates batches
of email messages. To avoid the Outlook security prompts, I use Redemption
to generate and send the messages. The application was developed on a
Windows NT 4.0 workstation and installed (until recently) on my user's
Windows NT 4.0 workstation.

Everything has gone fairly well until this week, when my user migrated to
Windows XP. I downloaded the latest version of Redemption and installed my
application on my user's computer. But when my user tries to run the
application, it fails with error 91: Object variable or with block variable
not set. As far as I can tell, the error appears whenever I try to access
the .Recipients collection of the Redemption message my program creates.
But the same executable runs without error on my NT 4.0 workstation.

I've run into a dead end on this. Is there something I have to change in my
code to make it work under XP?

Here's the code (with irrelevant stuff deleted):

Dim rdmSafeMessage As Redemption.SafeMailItem
Dim myOlApp As Outlook.Application
Dim myOlNameSpace As Outlook.NameSpace
Dim myOlMessage As Outlook.MailItem
Dim myRecip As Redemption.SafeRecipient
Dim myRecips As Redemption.SafeRecipients

On Error GoTo ErrHandler
Set myOlApp = New Outlook.Application
Set myOlNameSpace = myOlApp.GetNamespace("MAPI")
myOlNameSpace.Logon
iMessageCount = 0
[...]
adcAddressee.Recordset.MoveFirst
Do Until adcAddressee.Recordset.EOF
10: bSendOK = True
20: Set myOlMessage = myOlApp.CreateItem(0)
30: Set rdmSafeMessage = CreateObject("Redemption.SafeMailItem")
myOlMessage.Save
40: rdmSafeMessage.Item = myOlMessage
43: MsgBox Str(rdmSafeMessage.Recipients.Count), , "recips"
50: sEmail = adcAddressee.Recordset(0)

[...(building message body)...]

90: iMessageCount = iMessageCount + 1
If bSendOK Then

100: With rdmSafeMessage
101: Set myRecip = .Recipients.Add(sEmail)
MsgBox myRecip.Name, , "name"
102: .Subject = "You are invited to participate in a survey"

[...(more body building)...]

107: .Body = sBody

108: .Recipients.ResolveAll
109: If chkPreview = vbChecked Then
.Display
If iMessageCount >= iMessageMax Then Exit Do
Else
.Send
120: End If
StatusBar1.Panels(2).Text = iMessageCount
End With
End If
adcAddressee.Recordset.MoveNext
Loop
adcAddressee.Recordset.Close
cmdSendMail.Enabled = False
Exit Sub

Error 91 appears at line 43: (a debugging message), 101: and 108.

I'd appreciate any help that anybody can offer.

Mitch Nussbaum
Wisconsin Dept of Natural Resources
 
D

Dmitry Streblechenko

Looks perfectly fine to me. What was your previous version of Redemption?
Didyou try to reset the project references? What if you dim rdmSafeMessage
as Object instead of Redemption.SafeMailItem?

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


Mitchell Nussbaum said:
I wrote and maintain a fairly simple VB6 application that generates batches
of email messages. To avoid the Outlook security prompts, I use Redemption
to generate and send the messages. The application was developed on a
Windows NT 4.0 workstation and installed (until recently) on my user's
Windows NT 4.0 workstation.

Everything has gone fairly well until this week, when my user migrated to
Windows XP. I downloaded the latest version of Redemption and installed my
application on my user's computer. But when my user tries to run the
application, it fails with error 91: Object variable or with block variable
not set. As far as I can tell, the error appears whenever I try to access
the .Recipients collection of the Redemption message my program creates.
But the same executable runs without error on my NT 4.0 workstation.

I've run into a dead end on this. Is there something I have to change in my
code to make it work under XP?

Here's the code (with irrelevant stuff deleted):

Dim rdmSafeMessage As Redemption.SafeMailItem
Dim myOlApp As Outlook.Application
Dim myOlNameSpace As Outlook.NameSpace
Dim myOlMessage As Outlook.MailItem
Dim myRecip As Redemption.SafeRecipient
Dim myRecips As Redemption.SafeRecipients

On Error GoTo ErrHandler
Set myOlApp = New Outlook.Application
Set myOlNameSpace = myOlApp.GetNamespace("MAPI")
myOlNameSpace.Logon
iMessageCount = 0
[...]
adcAddressee.Recordset.MoveFirst
Do Until adcAddressee.Recordset.EOF
10: bSendOK = True
20: Set myOlMessage = myOlApp.CreateItem(0)
30: Set rdmSafeMessage = CreateObject("Redemption.SafeMailItem")
myOlMessage.Save
40: rdmSafeMessage.Item = myOlMessage
43: MsgBox Str(rdmSafeMessage.Recipients.Count), , "recips"
50: sEmail = adcAddressee.Recordset(0)

[...(building message body)...]

90: iMessageCount = iMessageCount + 1
If bSendOK Then

100: With rdmSafeMessage
101: Set myRecip = .Recipients.Add(sEmail)
MsgBox myRecip.Name, , "name"
102: .Subject = "You are invited to participate in a survey"

[...(more body building)...]

107: .Body = sBody

108: .Recipients.ResolveAll
109: If chkPreview = vbChecked Then
.Display
If iMessageCount >= iMessageMax Then Exit Do
Else
.Send
120: End If
StatusBar1.Panels(2).Text = iMessageCount
End With
End If
adcAddressee.Recordset.MoveNext
Loop
adcAddressee.Recordset.Close
cmdSendMail.Enabled = False
Exit Sub

Error 91 appears at line 43: (a debugging message), 101: and 108.

I'd appreciate any help that anybody can offer.

Mitch Nussbaum
Wisconsin Dept of Natural Resources
 
M

Mitchell Nussbaum

I changed the dim statement for rdmSafeMessage, and the errors went away!

Thanks for your help.

Why should a change from early binding to late binding make a difference
like this?


Dmitry Streblechenko said:
Looks perfectly fine to me. What was your previous version of Redemption?
Didyou try to reset the project references? What if you dim rdmSafeMessage
as Object instead of Redemption.SafeMailItem?

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


Mitchell Nussbaum said:
I wrote and maintain a fairly simple VB6 application that generates batches
of email messages. To avoid the Outlook security prompts, I use Redemption
to generate and send the messages. The application was developed on a
Windows NT 4.0 workstation and installed (until recently) on my user's
Windows NT 4.0 workstation.

Everything has gone fairly well until this week, when my user migrated to
Windows XP. I downloaded the latest version of Redemption and installed my
application on my user's computer. But when my user tries to run the
application, it fails with error 91: Object variable or with block variable
not set. As far as I can tell, the error appears whenever I try to access
the .Recipients collection of the Redemption message my program creates.
But the same executable runs without error on my NT 4.0 workstation.

I've run into a dead end on this. Is there something I have to change
in
my
code to make it work under XP?

Here's the code (with irrelevant stuff deleted):

Dim rdmSafeMessage As Redemption.SafeMailItem
Dim myOlApp As Outlook.Application
Dim myOlNameSpace As Outlook.NameSpace
Dim myOlMessage As Outlook.MailItem
Dim myRecip As Redemption.SafeRecipient
Dim myRecips As Redemption.SafeRecipients

On Error GoTo ErrHandler
Set myOlApp = New Outlook.Application
Set myOlNameSpace = myOlApp.GetNamespace("MAPI")
myOlNameSpace.Logon
iMessageCount = 0
[...]
adcAddressee.Recordset.MoveFirst
Do Until adcAddressee.Recordset.EOF
10: bSendOK = True
20: Set myOlMessage = myOlApp.CreateItem(0)
30: Set rdmSafeMessage = CreateObject("Redemption.SafeMailItem")
myOlMessage.Save
40: rdmSafeMessage.Item = myOlMessage
43: MsgBox Str(rdmSafeMessage.Recipients.Count), , "recips"
50: sEmail = adcAddressee.Recordset(0)

[...(building message body)...]

90: iMessageCount = iMessageCount + 1
If bSendOK Then

100: With rdmSafeMessage
101: Set myRecip = .Recipients.Add(sEmail)
MsgBox myRecip.Name, , "name"
102: .Subject = "You are invited to participate in a survey"

[...(more body building)...]

107: .Body = sBody

108: .Recipients.ResolveAll
109: If chkPreview = vbChecked Then
.Display
If iMessageCount >= iMessageMax Then Exit Do
Else
.Send
120: End If
StatusBar1.Panels(2).Text = iMessageCount
End With
End If
adcAddressee.Recordset.MoveNext
Loop
adcAddressee.Recordset.Close
cmdSendMail.Enabled = False
Exit Sub

Error 91 appears at line 43: (a debugging message), 101: and 108.

I'd appreciate any help that anybody can offer.

Mitch Nussbaum
Wisconsin Dept of Natural Resources
 
D

Dmitry Streblechenko

If you used a fairly old version of Redemption (2.x), there was a change in
the SafeMailItem interface v-table around the 3.0 version. If the project
still used the 2.x definition, it would end up calling a wrong method due to
the v-table change.

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


Mitchell Nussbaum said:
I changed the dim statement for rdmSafeMessage, and the errors went away!

Thanks for your help.

Why should a change from early binding to late binding make a difference
like this?


Dmitry Streblechenko said:
Looks perfectly fine to me. What was your previous version of Redemption?
Didyou try to reset the project references? What if you dim rdmSafeMessage
as Object instead of Redemption.SafeMailItem?

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


Mitchell Nussbaum said:
I wrote and maintain a fairly simple VB6 application that generates batches
of email messages. To avoid the Outlook security prompts, I use Redemption
to generate and send the messages. The application was developed on a
Windows NT 4.0 workstation and installed (until recently) on my user's
Windows NT 4.0 workstation.

Everything has gone fairly well until this week, when my user migrated to
Windows XP. I downloaded the latest version of Redemption and
installed
my
application on my user's computer. But when my user tries to run the
application, it fails with error 91: Object variable or with block variable
not set. As far as I can tell, the error appears whenever I try to access
the .Recipients collection of the Redemption message my program creates.
But the same executable runs without error on my NT 4.0 workstation.

I've run into a dead end on this. Is there something I have to change
in
my
code to make it work under XP?

Here's the code (with irrelevant stuff deleted):

Dim rdmSafeMessage As Redemption.SafeMailItem
Dim myOlApp As Outlook.Application
Dim myOlNameSpace As Outlook.NameSpace
Dim myOlMessage As Outlook.MailItem
Dim myRecip As Redemption.SafeRecipient
Dim myRecips As Redemption.SafeRecipients

On Error GoTo ErrHandler
Set myOlApp = New Outlook.Application
Set myOlNameSpace = myOlApp.GetNamespace("MAPI")
myOlNameSpace.Logon
iMessageCount = 0
[...]
adcAddressee.Recordset.MoveFirst
Do Until adcAddressee.Recordset.EOF
10: bSendOK = True
20: Set myOlMessage = myOlApp.CreateItem(0)
30: Set rdmSafeMessage = CreateObject("Redemption.SafeMailItem")
myOlMessage.Save
40: rdmSafeMessage.Item = myOlMessage
43: MsgBox Str(rdmSafeMessage.Recipients.Count), , "recips"
50: sEmail = adcAddressee.Recordset(0)

[...(building message body)...]

90: iMessageCount = iMessageCount + 1
If bSendOK Then

100: With rdmSafeMessage
101: Set myRecip = .Recipients.Add(sEmail)
MsgBox myRecip.Name, , "name"
102: .Subject = "You are invited to participate in a survey"

[...(more body building)...]

107: .Body = sBody

108: .Recipients.ResolveAll
109: If chkPreview = vbChecked Then
.Display
If iMessageCount >= iMessageMax Then Exit Do
Else
.Send
120: End If
StatusBar1.Panels(2).Text = iMessageCount
End With
End If
adcAddressee.Recordset.MoveNext
Loop
adcAddressee.Recordset.Close
cmdSendMail.Enabled = False
Exit Sub

Error 91 appears at line 43: (a debugging message), 101: and 108.

I'd appreciate any help that anybody can offer.

Mitch Nussbaum
Wisconsin Dept of Natural Resources
 

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