G
Guest
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
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