hello,
I have some VB code that automatically composes an send an e-mail via Outlook 2002 and I've been having the problem of after the VB code executable has finished running the Outlook.exe process is left running in the background, which I can see when I look in the Processes tab of Windows Task Manager.
What changes do I have to do to the code to make the Outlook.exe process properly close after the e-mail has been sent and the VB code has finished executing?
thanks in advance,
david
------------
------------
I have some VB code that automatically composes an send an e-mail via Outlook 2002 and I've been having the problem of after the VB code executable has finished running the Outlook.exe process is left running in the background, which I can see when I look in the Processes tab of Windows Task Manager.
What changes do I have to do to the code to make the Outlook.exe process properly close after the e-mail has been sent and the VB code has finished executing?
thanks in advance,
david
------------
Code:
Dim OutApp As Object
Dim OutMail As Object
Dim SigString As String
Dim Signature As String
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
'figure out how to randomize the number to go between 2 and whatever # I'm up to'
SigString = "C:\Documents and Settings\Admin\Application Data\Microsoft\Signatures\dgr2.htm"
If Dir(SigString) <> "" Then
Signature = GetBoiler(SigString)
Else
Signature = "where's the signature?"
End If
On Error Resume Next
With OutMail
.To = "m.Min@RorSncis.com"
.CC = "ra@critdjume.com"
.BCC = ""
.Subject = "CABCALLS & CABLETTERS record counts for " & Format(Date, "mm/dd/yy")
.HTMLBody = "Hello Pam:<br><br>" & _
"For " & Format(Date, "mm/dd/yy") & ":          # of Records<br>" & _
"CABLETTERS.TXT    " & CABLETTERSlineCount & "<br>" & _
"CABCALLS.TXT        " & CABCALLSlineCount & "<br><br>" & Signature
.Display
End With
On Error GoTo 0
TimeDelay (4)
AppActivate OutMail
VbSendKeys "^{ENTER}"
AppActivate OutMail
VbSendKeys "%{F4}"
AppActivate OutMail
VbSendKeys "Y"
Set OutMail = Nothing
Set OutApp = Nothing