R
Rod
I am running a VBA program in Access to send emails. The email is sent OK
but Outlook stays in memory.
In the code below I have put in a message box to slow the code down. If this
is there then Outlook correctly closes itself down.
Because it is not closed it creates problems the next time I call the code,
even if it is modified to pick up an already open version of outlook.
I am using Office 2002 on a Vista machine with several cpus
Any suggestions please
many thanks
--------------------------------
Public Sub Create_eMails()
Dim olApp As New Outlook.Application
Dim olNs As Outlook.NameSpace
Dim OBmailItem As Outlook.MailItem
Set olApp = New Outlook.Application
Set olNs = olApp.GetNamespace("MAPI")
olNs.Logon ""
Set OBmailItem = olApp.CreateItem(olMailItem)
OBmailItem.To = "(e-mail address removed)"
OBmailItem.Subject = "Test Email. "
OBmailItem.Body = "Test Body Text "
OBmailItem.Send
Call MsgBox("Wait")
olNs.Logoff
olApp.Quit
Set OBmailItem = Nothing
Set olNs = Nothing
Set olApp = Nothing
End Sub
but Outlook stays in memory.
In the code below I have put in a message box to slow the code down. If this
is there then Outlook correctly closes itself down.
Because it is not closed it creates problems the next time I call the code,
even if it is modified to pick up an already open version of outlook.
I am using Office 2002 on a Vista machine with several cpus
Any suggestions please
many thanks
--------------------------------
Public Sub Create_eMails()
Dim olApp As New Outlook.Application
Dim olNs As Outlook.NameSpace
Dim OBmailItem As Outlook.MailItem
Set olApp = New Outlook.Application
Set olNs = olApp.GetNamespace("MAPI")
olNs.Logon ""
Set OBmailItem = olApp.CreateItem(olMailItem)
OBmailItem.To = "(e-mail address removed)"
OBmailItem.Subject = "Test Email. "
OBmailItem.Body = "Test Body Text "
OBmailItem.Send
Call MsgBox("Wait")
olNs.Logoff
olApp.Quit
Set OBmailItem = Nothing
Set olNs = Nothing
Set olApp = Nothing
End Sub