J
Jack III
The code below works fine as long as Outlook is open already. I
outlook is closed it won't work. Could anyone suggest how to ope
automatically open Outlook if it's not already opened?
Thank you,
Private Sub Form_Dirty(Cancel As Integer)
Dim NameSpace As Object
Dim EmailSend As TaskItem 'for the task item
Dim EmailApp As Object
Dim strProjectID As Integer
Dim strEmail As Object
Dim strPlanner As Object
Dim strFloor As Object
Dim strBLD As Object
Set strFloor = Me.Floor
Set strBLD = Me.BLD
Set strPlanner = Me.Planner
Set strEmail = Me.Email
Set strID = Me.Project_ID
Set EmailApp = CreateObject("Outlook.Application") 'outlook object
Set NameSpace = EmailApp.getNameSpace("MAPI")
Set EmailSend = EmailApp.CreateItem(3) 'CreateItem(0)Mail Item
'CreateItem(1)Appointment Item
'CreateItem(2)Contact Item
'CreateItem(3)Task Item
'CreateItem(4)Journal Item
'CreateItem(5)Note Item
'CreateItem(6)Post Item
'CreateItem(0)Dist. List Item
EmailSend.Subject = "Move complete for Project" & " " & strID 'tas
subject
EmailSend.Body = strPlanner & "," & " " & "Project" & " " & strID & "
& "(" & strBLD & " " & strFloor & ")" & " " & "is ready to be punched.
'task body
EmailSend.Recipients.Add (strEmail) 'first add the email or user as
recipient
EmailSend.Assign 'assign previously added recipient to the task
EmailSend.Send 'send the task
End Su
outlook is closed it won't work. Could anyone suggest how to ope
automatically open Outlook if it's not already opened?
Thank you,
Private Sub Form_Dirty(Cancel As Integer)
Dim NameSpace As Object
Dim EmailSend As TaskItem 'for the task item
Dim EmailApp As Object
Dim strProjectID As Integer
Dim strEmail As Object
Dim strPlanner As Object
Dim strFloor As Object
Dim strBLD As Object
Set strFloor = Me.Floor
Set strBLD = Me.BLD
Set strPlanner = Me.Planner
Set strEmail = Me.Email
Set strID = Me.Project_ID
Set EmailApp = CreateObject("Outlook.Application") 'outlook object
Set NameSpace = EmailApp.getNameSpace("MAPI")
Set EmailSend = EmailApp.CreateItem(3) 'CreateItem(0)Mail Item
'CreateItem(1)Appointment Item
'CreateItem(2)Contact Item
'CreateItem(3)Task Item
'CreateItem(4)Journal Item
'CreateItem(5)Note Item
'CreateItem(6)Post Item
'CreateItem(0)Dist. List Item
EmailSend.Subject = "Move complete for Project" & " " & strID 'tas
subject
EmailSend.Body = strPlanner & "," & " " & "Project" & " " & strID & "
& "(" & strBLD & " " & strFloor & ")" & " " & "is ready to be punched.
'task body
EmailSend.Recipients.Add (strEmail) 'first add the email or user as
recipient
EmailSend.Assign 'assign previously added recipient to the task
EmailSend.Send 'send the task
End Su