Hi,
I'm fairly new to access and still learning alot. I am making a "Maintenance Work Order Request" database for my company and on my form of the new work order I have programmed in a control button "Submit Order" to send an automatic email to the applicable maintenance department people. I have it working properly, but the problem I'm running into is that it wont send the email if the outlook app isn't opened on the users computer. Is there a way to still send the email without the user having to have their outlook opened up? My other question would be, I have written in the vba code to "SentOnBehalfofName" to make the emai "from" a dummy account "work_orders@company.com". This will be a shared database and probably up to 10 people will be able to get on and submit a work order. Will my "SentOnBehalf" email code still work on another users computer? Or will it only work from my computer? Any help would be greatly appreciated. Here is my current code:
Code:
Private Sub Enter_Record_Click()
Dim oOutlook As Outlook.Application
Dim oEmailItem As MailItem
Set oOutlook = GetObject(, "Outlook.Application")
If oOutlook Is Nothing Then
Set oOutlook = New Outlook.Application
End If
Set oEmailItem = oOutlook.CreateItem(olMailItem)
With oEmailItem
End With
'assign message to HMTL.body
Body = oEmailItem.HTMLBody
With oEmailItem
.SentOnBehalfOfName = "Work_Orders@company.com"
.To = "kip.andrews@company.com"
.Subject = "New Work Order Submission"
'Adding body text
Dim mymsg As String
mymsg = "A new work order request has been submitted and is ready for you to review!" & vbCrLf
mymsg = mymsg & "Please login at your earliest convenience and update the order." & vbCrLf & vbCrLf
mymsg = mymsg & "Sincerely," & vbCrLf & vbCrLf
mymsg = mymsg & "WORCS_Admin" & vbCrLf
mymsg = mymsg & "My Company"
.Body = mymsg
.Send
End With
Set oEmailItem = Nothing
Set oOutlook = Nothing
'DoCmd.OpenForm "WORCS_MsgBox", acNormal, "", "", , acNormal
DoCmd.OpenForm "WORCS_MsgBox", acNormal, , , , acWindowNormal
DoCmd.Close acForm, Me.Name
End Sub