Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I set up Outlook email? | New Users to Excel | |||
message box to print or email when closing workbook | Excel Discussion (Misc queries) | |||
Outlook Email | New Users to Excel | |||
Startup and template locations in Citrix TS session and local session | Setting up and Configuration of Excel | |||
Email & Outlook | Excel Discussion (Misc queries) |