Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Email - Outlook no Closing Session

Hi All
I am using thse following to mail some information from Excel, whether
Outlook is currently running or not, I end up wth an instance of Outlook
that does not close. Everytime I call this it create another instance.
Why?

TIA
Cheers
Nigel

Private Sub EMail()
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To =
.Subject = "Test"
.Body = "Test"
'.Attachments.Add
.DeleteAfterSubmit
On Error Resume Next
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub




----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! 100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default Email - Outlook no Closing Session

Nigel,

Try adding OutApp.Quit at the end.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Nigel" wrote in message
...
Hi All
I am using thse following to mail some information from Excel, whether
Outlook is currently running or not, I end up wth an instance of Outlook
that does not close. Everytime I call this it create another instance.
Why?

TIA
Cheers
Nigel

Private Sub EMail()
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To =
.Subject = "Test"
.Body = "Test"
'.Attachments.Add
.DeleteAfterSubmit
On Error Resume Next
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub




----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet

News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! 100,000
Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption

=---


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Email - Outlook no Closing Session

Hi Nigel,
Set OutApp has created a new instance of OutLook, whether one exists
or not.
Try this. ObjoutLook is first of all set to an existing instance of
OutLook. If this fails (i.e. OutLook is not running) then an error is
generated and outLookWasRunning is set to False. If that is the case,
objOutLook is set to a new instance of OutLook.

Dim OutLookWasRunning as Boolean
On Error Resume Next
Err.Clear 'Err is Public and might have a value
Set objOutlook = GetObject(, "Outlook.Application") 'If Outlook is
already _
open, flag it
with Boolean
If Err.Number < 0 Then
OutlookWasRunning = False
Else
OutlookWasRunning = True
end if
On Error GoTo 0
Err.Clear 'keep err tidy
If Not OutlookWasRunning Then
Set objOutlook = CreateObject("Outlook.Application") 'fresh
version of _
Outlook
End If

At the end of your sub you could also put,

If Not OutlookWasRunning Then objOutlook.Quit

So that you don't leave OutLook open when it wasn't open on the users
machine.

regards
Paul
"Nigel" wrote in message ...
Hi All
I am using thse following to mail some information from Excel, whether
Outlook is currently running or not, I end up wth an instance of Outlook
that does not close. Everytime I call this it create another instance.
Why?

TIA
Cheers
Nigel

Private Sub EMail()
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To =
.Subject = "Test"
.Body = "Test"
'.Attachments.Add
.DeleteAfterSubmit
On Error Resume Next
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub




----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! 100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Email - Outlook no Closing Session

Hi Nigel

Because there is a bug in Outlook it is possible that you must uncheck
"send immediately when connect" in the Outlook options.
<ToolsOptionsMail Setup in the Outlook menu

Problem :
It will not close the Outlook process after the mail is sent in the Task Manager

This seems to be fixed in Office 2003


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Nigel" wrote in message ...
Hi All
I am using thse following to mail some information from Excel, whether
Outlook is currently running or not, I end up wth an instance of Outlook
that does not close. Everytime I call this it create another instance.
Why?

TIA
Cheers
Nigel

Private Sub EMail()
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To =
.Subject = "Test"
.Body = "Test"
'.Attachments.Add
.DeleteAfterSubmit
On Error Resume Next
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub




----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! 100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Email - Outlook no Closing Session

Thanks everyone for the feedback and advice, I shall try it.

Curiously in my development environment (XP Pro / Excel 2002-SP2 / Outlook
2002 -SP2) is where I have the problem. On the target PCs - corporate
network, NT4 / Excel97 / Outlook97 the problem does not appear, but this
might be a function of the network setup?. Anyway I'll set the App to Quit
if I create an instance otherwise use the one running and leave it open.

Cheers
Nigel



"Ron de Bruin" wrote in message
...
Hi Nigel

Because there is a bug in Outlook it is possible that you must uncheck
"send immediately when connect" in the Outlook options.
<ToolsOptionsMail Setup in the Outlook menu

Problem :
It will not close the Outlook process after the mail is sent in the Task

Manager

This seems to be fixed in Office 2003


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Nigel" wrote in message

...
Hi All
I am using thse following to mail some information from Excel, whether
Outlook is currently running or not, I end up wth an instance of Outlook
that does not close. Everytime I call this it create another instance.
Why?

TIA
Cheers
Nigel

Private Sub EMail()
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To =
.Subject = "Test"
.Body = "Test"
'.Attachments.Add
.DeleteAfterSubmit
On Error Resume Next
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub




----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet

News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! 100,000
Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via

Encryption =---






----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! 100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Email - Outlook no Closing Session

Ron,

Absolutely right, unchecking the box fixed it, the .Quit method now works OK

Cheers
Nigel




"Ron de Bruin" wrote in message
...
Hi Nigel

Because there is a bug in Outlook it is possible that you must uncheck
"send immediately when connect" in the Outlook options.
<ToolsOptionsMail Setup in the Outlook menu

Problem :
It will not close the Outlook process after the mail is sent in the Task

Manager

This seems to be fixed in Office 2003


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Nigel" wrote in message

...
Hi All
I am using thse following to mail some information from Excel, whether
Outlook is currently running or not, I end up wth an instance of Outlook
that does not close. Everytime I call this it create another instance.
Why?

TIA
Cheers
Nigel

Private Sub EMail()
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To =
.Subject = "Test"
.Body = "Test"
'.Attachments.Add
.DeleteAfterSubmit
On Error Resume Next
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub




----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet

News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! 100,000
Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via

Encryption =---






----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! 100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Email - Outlook no Closing Session

You don't need the Quit Nigel
Setting it to nothing is enough



--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Nigel" wrote in message ...
Ron,

Absolutely right, unchecking the box fixed it, the .Quit method now works OK

Cheers
Nigel




"Ron de Bruin" wrote in message
...
Hi Nigel

Because there is a bug in Outlook it is possible that you must uncheck
"send immediately when connect" in the Outlook options.
<ToolsOptionsMail Setup in the Outlook menu

Problem :
It will not close the Outlook process after the mail is sent in the Task

Manager

This seems to be fixed in Office 2003


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Nigel" wrote in message

...
Hi All
I am using thse following to mail some information from Excel, whether
Outlook is currently running or not, I end up wth an instance of Outlook
that does not close. Everytime I call this it create another instance.
Why?

TIA
Cheers
Nigel

Private Sub EMail()
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To =
.Subject = "Test"
.Body = "Test"
'.Attachments.Add
.DeleteAfterSubmit
On Error Resume Next
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub




----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet

News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! 100,000
Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via

Encryption =---






----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! 100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I set up Outlook email? new at outlook set up New Users to Excel 2 March 5th 09 08:31 AM
message box to print or email when closing workbook tom n.[_2_] Excel Discussion (Misc queries) 0 October 7th 08 05:58 PM
Outlook Email Jame-O New Users to Excel 1 November 7th 06 05:53 PM
Startup and template locations in Citrix TS session and local session John Nurick Setting up and Configuration of Excel 2 September 21st 06 10:42 PM
Email & Outlook Chris Excel Discussion (Misc queries) 0 March 14th 06 12:04 PM


All times are GMT +1. The time now is 05:43 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"