feeding Access records into outlook : "RUN TIME ERROR - item has been moved "

  • Thread starter Thread starter J Bard
  • Start date Start date
J

J Bard

RUN TIME ERROR - item has been moved or deleted is drive'n me crazy ..
just looping through some records feeding into Outlook mail - I get this
error on mi.to = rs!email , where mi is an outlook mailitem ....
It didn't happen as I was feeding static data into outlook in a test
mode...
 
How are you instantiating mi?
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 
Ms. Mosher (one of my newsgroup heros, by the way) , here's the whole thing
:

Dim oa As Outlook.Application
Dim ns As Outlook.NameSpace
Dim mi As Outlook.MailItem

Set oa = New Outlook.Application
Set ns = oa.GetNamespace("mapi")
Set mi = oa.CreateItem(olMailItem)

Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("company")
rs.MoveFirst

Do While Not rs.EOF
If rs!salesperson = Me!Combo0.Value Then
pos = InStr(rs!email, "@")
If pos <> 0 Then 'ok email if it's got @
Debug.Print rs!email
' Stop
mi.To = rs!email

mi.Subject = "test"
mi.Body = "a test"
mi.Send

' Stop
End If 'legit email data


End If 'the salesperson


rs.MoveNext


Loop



Set oa = Nothing
Set ns = Nothing
Set mi = Nothing

How are you instantiating mi?
--
Sue Mosher, Outlook MVP
Outlook and Exchange solutions at http://www.slipstick.com
Author of
Microsoft Outlook Programming: Jumpstart
for Administrators, Power Users, and Developers
 
Got it ...
I see I have to set mi to nothing and then re-create the mi after each send
....
 
Back
Top