Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Outlook 2007 from Access 2007 1

Status
Not open for further replies.

bocker

Programmer
Mar 9, 2001
81
US
I am not real experienced with 2007 at this point. I am double clicking an email text box to open up Outlook. The code does everything I want it to do except when I send the email and close Outlook I am finding out that it doesn't really close Outlook. After returning to my form everything is Ok with the form. If I try and open up Outlook again it won't open unless I reboot the computer.

The following code is what I am using. It seems to work fine in 2003. I am at work with a Access 2003 so any help I will need to try it after work at home.

Private Sub C1Email_DblClick(Cancel As Integer)

On Error GoTo Err_C1Email_DblClick

Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Dim EmailAddress As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
Forms(1).C1Email.SetFocus
EmailAddress = Forms(1).C1Email.Text
With OutMail
.To = EmailAddress
.CC = ""
.BCC = ""
.Subject = ""
.Body = ""
.Display 'or when your ready to really email use .Send

End With

Set OutMail = Nothing
Set OutApp = Nothing

Exit_C1Email_DblClick:
Exit Sub

Err_C1Email_DblClick:
MsgBox Err.Description
Resume Exit_C1Email_DblClick

End Sub
 

Outlook only allows one session to be open on a workstation, which is why you can't get it to reopen... you never close it in the code, and you don't make it visible, so it sits there disconnected but open after the 'Set OutApp = Nothing' statement.

Try OutApp.Quit immediately before setting it to Nothing.
 
Thanks! I will try it when I get home.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top