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

Open MS Outlook from Access

0 views
Skip to first unread message

Debbie

unread,
Sep 13, 2005, 10:43:02 PM9/13/05
to

Hello,
I have a button on an Access form that when clicked, I would like the
program to to open MS Outlook to a new message screen so that the user can
type an email. It should check to see if Outlook is already opened. If it
is opened, use that instance and if not, open a new one. I would like
Outlook to become the active window so that the user could do this. In my
reading the forums, I came up with this:

Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim MsgText As String
Dim MeetingType As String

'Create the Outlook session
'Set objOutlook = New Outlook.Application
Set objOutlook = GetObject(, "Outlook.Application")
If Err.Number <> 0 Then
Set objOutlook = CreateObject("Outlook.Application")
End If

'Create message
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

MeetingType = Forms!MeetingForm!MeetingType

With objOutlookMsg
Select Case MeetingType
Case "IHP"
.Subject = "IHP Meeting Attendees Verified"
Case "IDT"
.Subject = "IDT Meeting Attendees Verified"
End Select

End With

objOutlook.ActiveWindow
'Cleanup
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
Set objOutlookRecip = Nothing

When I run this code, nothing happens. What am I doing wrong? Also, how do
I wait to perform cleanup (set all objects to Nothing), till the user sends
the email? Thanks so much.
Debbie

David C. Holley

unread,
Sep 14, 2005, 9:58:08 AM9/14/05
to
Its not neccessy to DISPLAY the Outlook Application window to create a
new email message (or other Item for that matter).

Set objOutlook = CreateObject("Outlook.Application")

Set newMail = objOutlook.CreateItem(olMailItem)
newMail.display

But if you want the window to show...

Set myNameSpace = objOutlook.GetNameSpace("MAPI")
Set myFolder= myNameSpace.GetDefaultFolder(olFolderInbox)
myFolder.Display

Until you excute the .Display method of the object, the object exists
only in memory. (Like Rose in Titanic - He exists now only in my memory.)

David H

Debbie

unread,
Sep 14, 2005, 9:50:03 PM9/14/05
to
David,
Thank you so much! It works like a charm!
Debbie

David C. Holley

unread,
Sep 14, 2005, 11:52:18 PM9/14/05
to
Not that I have any experience with getting Access to control Outlook or
anything....(have been do so for what seems an eternity)
0 new messages