K
Keith
Hi
I am using Outlook Automation to send emails and assign tasks in a help desk
database I am, designing . I did have them as subs in my DB, but as they
started to grow, I decided to break them out and put them into a module as
functions. However, now I have done this nothing works! I click my command
button and nothing happens - no errors, no outlook.
Below is my code for sending a confirmation email via Outlook (both the sub
for calling the function and the function itself which resides in a module).
Can anyone suggest a reason why it would have stopped working? I considered
the possibility that these did not port over to functions well but I don't
know so I thought I'd ask the experts.
---
Private Sub cmdSendEmail_Click()
On Error GoTo Err_cmdSendEmail_Click
Me!HLP_Email.Value = Forms.SYS_Hardware!HDW_Email.Value
Call fncHelpDeskSendEmailOutlook
Exit_cmdSendEmail_Click:
Exit Sub
Err_cmdSendEmail_Click:
'MsgBox Err.Description
Resume Exit_cmdSendEmail_Click
End Sub
---
Function fncHelpDeskSendEmailOutlook()
Dim strEmail As String
Dim strBody As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
'**creates an instance of Outlook
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
'***email address to send to
strEmail = Forms![Sys_HelpDesk Subform].[HLP_Email]
'***main body of email
strBody = strBody & "Dear " & Forms![Sys_HelpDesk Subform].[HLP_ReportedBy]
& Chr(13) & Chr(13)
strBody = strBody & "Your IT Support issue has been logged on " &
Forms![Sys_HelpDesk Subform].[HLP_DateReported] & " at " &
Forms![Sys_HelpDesk Subform].[HLP_TimeReported] & _
", and has been assigned Call Number " & Forms![Sys_HelpDesk
Subform].[HLP_CallNumber] & "." & Chr(13) & Chr(13)
strBody = strBody & "Regards" & Chr(13) & Chr(13)
strBody = strBody & "Keith" & Chr(13)
'***creates and sends email
With objEmail
.To = strEmail
.Subject = "IT Support Request - Confirmation"
.Body = strBody
.Send
End With
'****end *****
Set objEmail = Nothing
'****closes Outlook
'objOutlook.Quit
End Function
I am using Outlook Automation to send emails and assign tasks in a help desk
database I am, designing . I did have them as subs in my DB, but as they
started to grow, I decided to break them out and put them into a module as
functions. However, now I have done this nothing works! I click my command
button and nothing happens - no errors, no outlook.
Below is my code for sending a confirmation email via Outlook (both the sub
for calling the function and the function itself which resides in a module).
Can anyone suggest a reason why it would have stopped working? I considered
the possibility that these did not port over to functions well but I don't
know so I thought I'd ask the experts.
---
Private Sub cmdSendEmail_Click()
On Error GoTo Err_cmdSendEmail_Click
Me!HLP_Email.Value = Forms.SYS_Hardware!HDW_Email.Value
Call fncHelpDeskSendEmailOutlook
Exit_cmdSendEmail_Click:
Exit Sub
Err_cmdSendEmail_Click:
'MsgBox Err.Description
Resume Exit_cmdSendEmail_Click
End Sub
---
Function fncHelpDeskSendEmailOutlook()
Dim strEmail As String
Dim strBody As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
'**creates an instance of Outlook
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
'***email address to send to
strEmail = Forms![Sys_HelpDesk Subform].[HLP_Email]
'***main body of email
strBody = strBody & "Dear " & Forms![Sys_HelpDesk Subform].[HLP_ReportedBy]
& Chr(13) & Chr(13)
strBody = strBody & "Your IT Support issue has been logged on " &
Forms![Sys_HelpDesk Subform].[HLP_DateReported] & " at " &
Forms![Sys_HelpDesk Subform].[HLP_TimeReported] & _
", and has been assigned Call Number " & Forms![Sys_HelpDesk
Subform].[HLP_CallNumber] & "." & Chr(13) & Chr(13)
strBody = strBody & "Regards" & Chr(13) & Chr(13)
strBody = strBody & "Keith" & Chr(13)
'***creates and sends email
With objEmail
.To = strEmail
.Subject = "IT Support Request - Confirmation"
.Body = strBody
.Send
End With
'****end *****
Set objEmail = Nothing
'****closes Outlook
'objOutlook.Quit
End Function