dbTalk Databases Forums  

Help with Outlook Automation

comp.databases.ms-access comp.databases.ms-access


Discuss Help with Outlook Automation in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
robboll
 
Posts: n/a

Default Help with Outlook Automation - 12-23-2009 , 10:04 PM






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

Reply With Quote
  #2  
Old   
Tom van Stiphout
 
Posts: n/a

Default Re: Help with Outlook Automation - 12-24-2009 , 09:14 AM






On Wed, 23 Dec 2009 19:04:43 -0800 (PST), robboll
<robboll (AT) hotmail (DOT) com> wrote:

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

-Tom.
Microsoft Access MVP


Quote:
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

Reply With Quote
  #3  
Old   
robboll
 
Posts: n/a

Default Re: Help with Outlook Automation - 12-30-2009 , 06:59 AM



On Dec 24, 8:14*am, Tom van Stiphout <tom7744.no.s... (AT) cox (DOT) net> wrote:
Quote:
On Wed, 23 Dec 2009 19:04:43 -0800 (PST), robboll

robb... (AT) hotmail (DOT) 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
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- 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.

Reply With Quote
  #4  
Old   
Tom van Stiphout
 
Posts: n/a

Default Re: Help with Outlook Automation - 12-30-2009 , 03:07 PM



On Wed, 30 Dec 2009 03:59:53 -0800 (PST), robboll
<robboll (AT) hotmail (DOT) 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



Quote:
On Dec 24, 8:14*am, Tom van Stiphout <tom7744.no.s... (AT) cox (DOT) net> wrote:
On Wed, 23 Dec 2009 19:04:43 -0800 (PST), robboll

robb... (AT) hotmail (DOT) 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
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- 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.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.