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
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