Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Help with Outlook Automation

18 views
Skip to first unread message

robboll

unread,
Dec 23, 2009, 10:04:43 PM12/23/09
to rpbol...@sbcglobal.net
I launch Outlook form MS Access 2003 using the code under the double
line.

When I send the first email it works fine. But if I send another
email everything freezes up. I have to use the task manager to Kill
OUTLOOK. And then it is immediatly replace by another OUTLOOK
session
and the email window comes up. I was wondering if my code could be
improved to prevent that from happening. Any suggestions please!


RBollinger


=======================================================
Private Sub Command11_Click()
On Error GoTo Err_Command11_Click


Dim stDocName, mTO, mCC, mSubject As String


stDocName = "frmSnapShot"
mTO = Forms!frmEmail!emailTO
mCC = Forms!frmEmail!emailCC
mSubject = Forms!frmEmail!Subject
mpath = Mid(Forms!frmIssues!FolderPath, InStr(1, Nz(Forms!
frmIssues!FolderPath), "#") + 1, 100)


DoCmd.SendObject acReport, stDocName, , mTO, mCC, , mSubject, IIf
(Forms!frmEmail!Check3 = -1, "Shared Directory:" & vbCrLf & mpath,
""), , False


Exit_Command11_Click:
Exit Sub


Err_Command11_Click:
MsgBox Err.Description


Exit Sub
email_error:
MsgBox "An error was encountered." & vbCrLf & "The error message is:
"
& Err.Description
Resume Error_out
Error_out:


End Sub


Tom van Stiphout

unread,
Dec 24, 2009, 9:14:55 AM12/24/09
to
On Wed, 23 Dec 2009 19:04:43 -0800 (PST), robboll
<rob...@hotmail.com> wrote:

Your code looks OK. Try it on a few other machines.

-Tom.
Microsoft Access MVP

robboll

unread,
Dec 30, 2009, 6:59:53 AM12/30/09
to
On Dec 24, 8:14 am, Tom van Stiphout <tom7744.no.s...@cox.net> wrote:
> On Wed, 23 Dec 2009 19:04:43 -0800 (PST), robboll
>
> <robb...@hotmail.com> wrote:
>
> Your code looks OK. Try it on a few other machines.
>
> -Tom.
> Microsoft Access MVP
>
>
>
> >I launch Outlook form MS Access 2003 using the code under the double
> >line.
>
> >When I send the first email it works fine.  But if I send another
> >email everythingfreezesup.  I have to use the task manager to Kill
> >End Sub- Hide quoted text -
>
> - Show quoted text -

I wonder if there is a way to ensure one session of Outlook at all
times? Where even if you want a seperate session of Outlook you can't.

Tom van Stiphout

unread,
Dec 30, 2009, 3:07:49 PM12/30/09
to
On Wed, 30 Dec 2009 03:59:53 -0800 (PST), robboll
<rob...@hotmail.com> wrote:

The standard way to do that is by using Automation. You will find many
articles online about the details. Essentially you first call
GetObject to see if an Outlook.Application object can be obtained. If
that fails, Outlook is not running and you call CreateObject to start
it. Using that object you then fabricate an email message and send it.

-Tom.
Microsoft Access MVP

0 new messages