Hi Guys
I have this code that runs after a tick box is ticked
'this requires a refrence to outlook object library
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
On Error Resume Next
'Get Outlook if it's running
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
'Outlook wasn't running, start it from code
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If
'Create a new mailitem
Set oItem = oOutlookApp.CreateItem(olMailItem)
With oItem
'Set the recipient for the new email
.BodyFormat = olFormatHTML
.To = Me.UsersEMailAddress
'.CC = DLookup("SupportEmail2", "Settings", "ID = 1")
.Subject = Me.NoteType
.HTMLBody = Me.Notes & "This Ticket Has Been Closed By " & Me.ClosedBy
'.Display
.Send
End With
If bStarted Then
'If we started Outlook from code, then close it
oOutlookApp.Quit
End If
Set oOutlookApp = Nothing
Set oItem = Nothing
MsgBox "This Ticket Has Been Closed. An E-Mail Has Been Sent To " & Me.OpenedBY, vbOKOnly, "This Ticket Has Been Marked As Closed"
End If
this works if outlook is open, but if its not no e-mail is sent,
how can I change this code so that outlook opens and sends the mail if it's not already open?
im really sorry if this has been asked before but the more I look at this the more confused I'm getting
many thanks
Steve