 | 
28-Jul-2006, 08:01 AM
|  | Guest | | | | | | | | | | creating an Outlook instance through Access VBA good day. Within an existing Access DB application, we have built a
module to allow users to send emails (through Outlook). Manual
intervention is necessary, in that users have to click 'send', to send
the email.
Opening the first session, and closing it is not a problem. I am having
trouble starting a second-, third- instance of Outlook, though. This is
very sporadic, and only happening to one of perhaps twenty users of the Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/information-technology/9288-creating-outlook-instance-through-access-vba.html
application (residing in a common folder).
Any ideas?
We have checked the references, and version # of reference files and Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9288
they are in sync with the PCs where this functionality is working just
groovy.
awaiting a speedy reply...
socka Got anything to share on This Topic? Why not share your immediate thoughts/reaction with us! Login Now! or Sign Up Today! to share your views... Gurfateh! | 
28-Jul-2006, 08:01 AM
|  | Guest | | | | | | | | | | Re: creating an Outlook instance through Access VBA Maybe I'm confused here, but are you allowed to open multiple sessions of
Outlook? In my experience, multiple instances (as viewed in Task Manager) Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9288
suggest a failure of some kind, like Outlook failed to close due to Active
Sync being attached. I know that's not your problem, but my question is,
Why do you want to open multiple instances of Outlook?
Once Outlook is open, then additional requests should use the open session.
Below is some code that demonstrates this, using GetObject() first to see if
you can attach to an open session, and then CreateObject() if that fails.
I may be way off here, but if so, then I simply misunderstood the question.
--
Danny J. Lesandrini dlesandrini@hotmail.com http://amazecreations.com/datafast wrote in message news:1147234225.881862.180130@i40g2000cwc.googlegr oups.com...
> good day. Within an existing Access DB application, we have built a
> module to allow users to send emails (through Outlook). Manual
> intervention is necessary, in that users have to click 'send', to send
> the email.
> Opening the first session, and closing it is not a problem. I am having
> trouble starting a second-, third- instance of Outlook, though. This is
> very sporadic, and only happening to one of perhaps twenty users of the
> application (residing in a common folder). Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9288
> Any ideas?
> We have checked the references, and version # of reference files and
> they are in sync with the PCs where this functionality is working just
> groovy.
>
> awaiting a speedy reply...
>
> socka
>
Option Compare Database
Option Explicit
Dim mOutlookApp As Outlook.Application
Dim mNameSpace As Outlook.NameSpace
Dim mFolder As MAPIFolder
Dim mItem As MailItem
Dim fSuccess As Boolean
' First function sets the Outlook Application
' and Namespase objects and opens MS Outlook
Public Function GetOutlook() As Boolean
On Error Resume Next
' Assume success
fSuccess = True
Set mOutlookApp = GetObject(, "Outlook.application")
' If Outlook is NOT Open, then there will be an error.
' In case of error, attempt to open Outlook
If Err.Number > 0 Then
Err.clear
Set mOutlookApp = CreateObject("Outlook.application")
If Err.Number > 0 Then
MsgBox "Could not create Outlook object", vbCritical
fSuccess = False
Exit Function
End If
End If
' If we've made it this far, we have an Outlook App Object
' Now, set the NameSpace object to MAPI Namespace
Set mNameSpace = mOutlookApp.GetNamespace("MAPI")
If Err.Number > 0 Then
MsgBox "Could not create NameSpace object", vbCritical
fSuccess = False
Exit Function
End If
GetOutlook = fSuccess
End Function
' Next function reads user entered values and
' actually sends the message
Public Function SendMessage() As Boolean
On Error Resume Next
Dim strRecip As String
Dim strSubject As String
Dim strMsg As String
Dim strAttachment As String
strSubject = Nz(Me!txtSubject,"")
strRecip = Nz(Me!txtRecipient,"")
strMsg = Nz(Me!txtBody,"")
strAttachment = Nz(Me!txtAttachment,"")
If Len(strRecip) = 0 Then
strMsg = "You must provide a recipient."
MsgBox strMsg, vbExclamation, "Error"
Exit Function
End If
' Assume success
fSuccess = True
If GetOutlook Then
Set mItem = mOutlookApp.CreateItem(olMailItem)
mItem.Recipients.Add strRecip
mItem.Subject = strSubject
mItem.Body = strMsg
If Len(strAttachment) > 0 Then
mItem.Attachments.Add strAttachment
End If
mItem.Save
mItem.Send
End If
If Err.Number > 0 Then fSuccess = False
SendMessage = fSuccess
End Function | 
Support Us! Become a Promoter! | | Gurfateh ji, you can become a SPN Promoter by Donating as little as $10 each month. With limited resources & high operational costs, your donations make it possible for us to deliver a quality website and spread the teachings of the Sri Guru Granth Sahib Ji, to serve & uplift humanity. Every contribution counts. Donate Generously. Gurfateh! | (View-All)
Members who have read this thread : 0
| | There are no names to display. | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | | | Tools | Search | | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is On | | | | » Active Discussions | | | | | | | | | | | Amrit Today 09:17 AM 5 Replies, 355 Views | | | | | | | | | | | | | | | | | | | » Books You Should Read... | | | |