Hello All,
This problem has been kicking my butt for two days now. I've searched everywhere I know and have yet to find a solution. The closest I've found was a note from Sue Mosher in a thread that says creating mails this way will not release the resources then there was a brief explenation on what to do about it, but the explanation didn't make any sense to me. I'm using Vis Stud 2008,
Word and Outlook 2007
I've added a For..Next loop to loop through and create several e-mails for testing. The actuall program loops through several records in a dataset and populates other parts of the word document based on that data, but when I strip it down to basics (below) it appears to be working fine, but 4 or 5 minutes after the process complets, my e-mail freezes up and won't start working again until I open task manager and force outlook to close.
I've tried setting "theMail" to MailItem, Outlook.MailItem and Word.MailItem all to no avail. Any help on this would be greatly appreciated!!!
For x = 0 To 10
Dim wordApp As Word.Application
Dim wordDoc As Word.Document
wordApp = New Word.Application
wordApp.Visible = True
wordDoc = wordApp.Documents.Add(Template:=theFile)
wordDoc.Bookmarks("theMonthDate").Range.Text = DateAndTime.Day(Now()) & " " & MonthName(Month(Now())) & ", " & Year(Now())
wordDoc.Bookmarks("theMonth").Range.Text = MonthName(Month(Now()))
wordDoc.Bookmarks("theMonth2").Range.Text = MonthName(Month(Now()))
''''other stuff that puplulates a table here based on a Recordset removed for testing purposes''''''''''
Dim theMail As Outlook.MailItem
theMail = wordDoc.MailEnvelope.Item
With theMail
.To = "a-jimp"
.Subject = "test" & Now()
.Save()
End With
wordDoc.Close(SaveChanges:=False)
wordDoc = Nothing
wordApp.Quit()
Next