troubleshooting Question

vb script - user defined type not defined.

Avatar of Mark Drelinger
Mark DrelingerFlag for United States of America asked on
VB ScriptMicrosoft OfficeVBA
2 Comments1 Solution92 ViewsLast Modified:
vb error started after Office 2010 upgrade. "User Defined Type not Defined".
Function EMailAlerts()
'Created by Helen Feddema 31-Oct-2009
'Last modified by Helen Feddema 31-Oct-2009

On Error GoTo ErrorHandler

   Dim dbs As DAO.Database
   Dim rst As DAO.Recordset
   Dim appOutlook As Outlook.Application (ERROR WAS POINTING TO THIS LINE)
   Dim msg As Outlook.MailItem
   Dim strEmail As String
   
   Set dbs = CurrentDb
   Set rst = dbs.OpenRecordset("qryExceptionList")
   Set appOutlook = GetObject(, "Outlook.Application")
   
   Do While Not rst.EOF
      strEmail = Nz(rst![EmailAddress]) & ";MarkDrelinger@SchmidtEquipment.com"
'      strEmail = "MarkDrelinger@SchmidtEquipment.com"
      If strEmail <> "" Then
         'Create email
         Set msg = appOutlook.CreateItem(olMailItem)
         msg.To = strEmail
         msg.Subject = "Machine Status or Location Change - Requested Alert"
         msg.Body = "Machine Status Change for Stock # " & (rst![StockNo]) & "." & vbCrLf & "Alert Requested by " & (rst![SubmittedBy]) & " on " & (rst![DateSubmitted]) & "." & vbCrLf & "Alert Comments: " & (rst![Comments]) & "." & vbCrLf
         msg.Body = msg.Body & vbCrLf & "Status changed from " & (rst![Original_Status_]) & " to " & (rst![New_Status_]) & vbCrLf
         msg.Body = msg.Body & "Branch changed from " & (rst![Original_Branch_]) & " to " & (rst![New_Branch_]) & vbCrLf
         msg.Body = msg.Body & vbCrLf & "To view or edit Alert Settings, click: https://www.teamschmidt.com/WebApps2.0/EquipmentDataDetailsAlertEdit.asp?varID=" & (rst![ID]) & vbCrLf & "To view MIM Details, click: https://www.teamschmidt.com/WebApps2.0/EquipmentDataDetails.asp?varStockNo=" & (rst![StockNo])
         'Comment out next line and uncomment Send line
         'to send automatically
         'msg.Display
         msg.Send
      End If
      rst.MoveNext
   Loop
   
ErrorHandlerExit:
   rst.Close
   Set rst = Nothing
   Set appOutlook = Nothing
   Exit Function

ErrorHandler:
   'Outlook is not running; open Outlook with CreateObject
   If Err.Number = 429 Then
      Set appOutlook = CreateObject("Outlook.Application")
      Resume Next
   Else
   If Err.Number = 287 Then
      Set appOutlook = CreateObject("Outlook.Application")
      Resume Next
   Else
      MsgBox "Error No: " & Err.Number _
         & " in EMailAllContacts procedure" _
         & "; Description: " & Err.Description
      Resume ErrorHandlerExit
   End If
      End If
End Function

Please advise if you have an idea what would need to be changed.
ASKER CERTIFIED SOLUTION
Michael Pfister

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros