![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Dear All, Office 2010 Access 2010 but still using an mdb-file for the moment. Outlook is running an minimized and should stay active !!! Each time I send an email Outlook opens a new session! I opens the current session with: Set ObjOutlook = GetObject(, "Outlook.application") and closes with objOutlook.Session.Logoff I can't see why it creates a new session ? Filip |
#3
| |||
| |||
|
|
Perhaps post the rest of your code. Perhaps you're inadvertently spawning another session somewhere. "Filips Benoit" <benoit.filips (AT) telenet (DOT) be> wrote in message news:Xj%uo.9360$HZ2.5190 (AT) newsfe30 (DOT) ams2... Dear All, Office 2010 Access 2010 but still using an mdb-file for the moment. Outlook is running an minimized and should stay active !!! Each time I send an email Outlook opens a new session! I opens the current session with: Set ObjOutlook = GetObject(, "Outlook.application") and closes with objOutlook.Session.Logoff I can't see why it creates a new session ? Filip |
#4
| |||
| |||
|
|
The code ! ------------------------------------------------------------------------------------------------------------------------------------------ Sub SendEmailNotVisible(EmailTo As String, Optional EmailSubject As String, Optional EmailBody As String, Optional AttachmentPath) On Error GoTo errHandling Dim objOutlook As Outlook.Application Dim objOutlookMsg As Outlook.MailItem Dim objOutlookRecip As Outlook.Recipient Dim objOutlookAttach As Outlook.Attachment ' Get the Outlook session. Set objOutlook = GetObject(, "Outlook.Application") ' Create the message. Set objOutlookMsg = objOutlook.CreateItem(olMailItem) With objOutlookMsg ' Add the To recipient(s) to the message. 'Set objOutlookMailTo = .Recipients.Add(EmailRecipient) 'objOutlookRecip.Type = olTo .To = EmailTo ' Add the CC recipient(s) to the message. 'Set objOutlookRecip = .Recipients.Add("nihil") 'objOutlookRecip.Type = olCC ' Set the Subject, Body, and Importance of the message. If Not IsMissing(EmailSubject) Then .Subject = EmailSubject If Not IsMissing(EmailBody) Then .Body = EmailBody .Importance = olImportanceHigh 'High importance ' Add attachments to the message. If Not IsMissing(AttachmentPath) Then Set objOutlookAttach = .Attachments.Add(AttachmentPath) End If ' Resolve each Recipient's name. 'For Each objOutlookRecip In .Recipients ' objOutlookRecip.Resolve ' Next ' Sending .Send End With Set objOutlookAttach = Nothing Set objOutlookRecip = Nothing Set objOutlookMsg = Nothing objOutlook.Session.Logoff 'objOutlook.Quit Set objOutlook = Nothing Exit Sub errHandling: objOutlookMsg.Close olDiscard Set objOutlookMsg = Nothing Set objOutlookAttach = Nothing Set objOutlookRecip = Nothing objOutlook.Quit Set objOutlook = Nothing MsgBox "Error in function SendEmailNotVisible: " & Err.Number & " " & Err.Description End Sub |
#5
| |||
| |||
|
|
"Filips Benoit" <benoit.filips (AT) telenet (DOT) be> wrote in message news:6Sbvo.7940$J84.7130 (AT) newsfe27 (DOT) ams2... The code ! ------------------------------------------------------------------------------------------------------------------------------------------ Sub SendEmailNotVisible(EmailTo As String, Optional EmailSubject As String, Optional EmailBody As String, Optional AttachmentPath) On Error GoTo errHandling Dim objOutlook As Outlook.Application Dim objOutlookMsg As Outlook.MailItem Dim objOutlookRecip As Outlook.Recipient Dim objOutlookAttach As Outlook.Attachment ' Get the Outlook session. Set objOutlook = GetObject(, "Outlook.Application") ' Create the message. Set objOutlookMsg = objOutlook.CreateItem(olMailItem) With objOutlookMsg ' Add the To recipient(s) to the message. 'Set objOutlookMailTo = .Recipients.Add(EmailRecipient) 'objOutlookRecip.Type = olTo .To = EmailTo ' Add the CC recipient(s) to the message. 'Set objOutlookRecip = .Recipients.Add("nihil") 'objOutlookRecip.Type = olCC ' Set the Subject, Body, and Importance of the message. If Not IsMissing(EmailSubject) Then .Subject = EmailSubject If Not IsMissing(EmailBody) Then .Body = EmailBody .Importance = olImportanceHigh 'High importance ' Add attachments to the message. If Not IsMissing(AttachmentPath) Then Set objOutlookAttach = .Attachments.Add(AttachmentPath) End If ' Resolve each Recipient's name. 'For Each objOutlookRecip In .Recipients ' objOutlookRecip.Resolve ' Next ' Sending .Send End With Set objOutlookAttach = Nothing Set objOutlookRecip = Nothing Set objOutlookMsg = Nothing objOutlook.Session.Logoff 'objOutlook.Quit Set objOutlook = Nothing Exit Sub errHandling: objOutlookMsg.Close olDiscard Set objOutlookMsg = Nothing Set objOutlookAttach = Nothing Set objOutlookRecip = Nothing objOutlook.Quit Set objOutlook = Nothing MsgBox "Error in function SendEmailNotVisible: " & Err.Number & " " & Err.Description End Sub Hmm. I don't see anything there that looks amiss. I do question why you are shutting down the session of Outlook if you want to use an active one... |
|
'objOutlook.Quit |
#6
| |||
| |||
|
|
"Filips Benoit" <benoit.filips (AT) telenet (DOT) be> wrote in message news:6Sbvo.7940$J84.7130 (AT) newsfe27 (DOT) ams2... The code ! ------------------------------------------------------------------------------------------------------------------------------------------ Sub SendEmailNotVisible(EmailTo As String, Optional EmailSubject As String, Optional EmailBody As String, Optional AttachmentPath) On Error GoTo errHandling Dim objOutlook As Outlook.Application Dim objOutlookMsg As Outlook.MailItem Dim objOutlookRecip As Outlook.Recipient Dim objOutlookAttach As Outlook.Attachment ' Get the Outlook session. Set objOutlook = GetObject(, "Outlook.Application") ' Create the message. Set objOutlookMsg = objOutlook.CreateItem(olMailItem) With objOutlookMsg ' Add the To recipient(s) to the message. 'Set objOutlookMailTo = .Recipients.Add(EmailRecipient) 'objOutlookRecip.Type = olTo .To = EmailTo ' Add the CC recipient(s) to the message. 'Set objOutlookRecip = .Recipients.Add("nihil") 'objOutlookRecip.Type = olCC ' Set the Subject, Body, and Importance of the message. If Not IsMissing(EmailSubject) Then .Subject = EmailSubject If Not IsMissing(EmailBody) Then .Body = EmailBody .Importance = olImportanceHigh 'High importance ' Add attachments to the message. If Not IsMissing(AttachmentPath) Then Set objOutlookAttach = .Attachments.Add(AttachmentPath) End If ' Resolve each Recipient's name. 'For Each objOutlookRecip In .Recipients ' objOutlookRecip.Resolve ' Next ' Sending .Send End With Set objOutlookAttach = Nothing Set objOutlookRecip = Nothing Set objOutlookMsg = Nothing objOutlook.Session.Logoff 'objOutlook.Quit Set objOutlook = Nothing Exit Sub errHandling: objOutlookMsg.Close olDiscard Set objOutlookMsg = Nothing Set objOutlookAttach = Nothing Set objOutlookRecip = Nothing objOutlook.Quit Set objOutlook = Nothing MsgBox "Error in function SendEmailNotVisible: " & Err.Number & " " & Err.Description End Sub Hmm. I don't see anything there that looks amiss. I do question why you are shutting down the session of Outlook if you want to use an active one... |
![]() |
| Thread Tools | |
| Display Modes | |
| |