The problem is this: Everything runs fine as far as Redemption code
is concerned, but then after a few minutes of inactivity in outlook,
when ever I try to send a new email, I get this error: "Operation
cannot be completed due to network or other communication problem.
Check your connection and try again". The email then just sits in the
outbox. Incoming email arrive just fine, only the outgoing cant be
sent. Also the outlook.exe process doesn't die, even if outlook is
closed. To start a new process I have to first kill the existing one
in task manager.
I have to restart outlook to fix the problem, but then if I run the
code again, after a few minutes of inactivity it happens again. I
have verified that if remove the VBA code below or never run it, then
outlook behaves just fine. So whenever I run it the problem happens a
few minutes after a period of inactivity. Version 2.0.0.536 which I
was using earlier had the same problem.
The code below causes the problem:
Public Sub Test()
Dim Dic As New Dictionary
Dim SMI As New SafeMailItem
Dim MI As MailItem
Set MI = Application.ActiveExplorer.CurrentFolder.Items(1)
SMI.Item = MI
MsgBox SMI.Sender.Address
SMI.Item = Nothing 'Removing this line has no effect
Set SMI = Nothing
Set Dic = Nothing
Set MI = Nothing
End Sub
Thanks,
Faraz Khan
PR_SENDER_EMAIL_ADDRESS = &H0C1F001E
MsgBox SMI.Fields(PR_SENDER_EMAIL_ADDRESS)
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
"Faraz Khan" <faraz...@asu.edu> wrote in message
news:a882fd73.03050...@posting.google.com...
--
George Hester
__________________________________
"Faraz Khan" <faraz...@asu.edu> wrote in message news:a882fd73.03050...@posting.google.com...
This line allocates a MailItem-size storage space, and initialises
it...
> Set MI = Application.ActiveExplorer.CurrentFolder.Items(1)
...and this line makes it point at something else. Is this legal VBA?
I'm new to VBA programming and might be misunderstanding the set
statement.
...Stu
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
I think you might be confusing the SMI variable with the MI variable.
MI variable is never intialized, it is only declared.
Even if MI was intializied then when I point MI to something else, VBA
(or VB) is smart enough to know that the real object in memory is no
longer in use, and so it will free up the space for us. But it is bad
practice to do that.
There are 2 keywords for assigning values or objects to variables, SET &
LET. The SET keyword is used for object variables and LET for values,
but LET is optional. For example:
Dim Obj as Object
Dim I as integer
LET I = 13 'LET is optional
I = 13 'same as above
SET Obj = Something
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
"Faraz Khan" <faraz...@asu.edu> wrote in message
news:#8Lv#sKGDH...@TK2MSFTNGP12.phx.gbl...
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
"George Hester" <heste...@hotmail.com> wrote in message
news:ezzsFo0F...@tk2msftngp13.phx.gbl...
--
George Hester
__________________________________
"Dmitry Streblechenko" <dmi...@dimastr.com> wrote in message news:uxohdWNG...@TK2MSFTNGP10.phx.gbl...
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
"George Hester" <heste...@hotmail.com> wrote in message
news:#6WshhWG...@tk2msftngp13.phx.gbl...
http://www.slipstick.com/dev/code/autoaddrecip.htm
--
George Hester
__________________________________
"Dmitry Streblechenko" <dmi...@dimastr.com> wrote in message news:#JnWQLYG...@tk2msftngp13.phx.gbl...
set Utils = CreateObject("Redemption.MAPIUtils")
Utils.Cleanup
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
"George Hester" <heste...@hotmail.com> wrote in message
news:OHajRedG...@TK2MSFTNGP10.phx.gbl...
--
George Hester
__________________________________
"Dmitry Streblechenko" <dmi...@dimastr.com> wrote in message news:#Q80azjG...@tk2msftngp13.phx.gbl...