Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

automating outlook 2003 from access 2003 form

Status
Not open for further replies.

kiwieur

Technical User
Apr 25, 2006
200
0
0
GB
I wonder if someone can help me, in the past I have been using the following code in access 2000 with outlook 2000.

Code:
Private Sub Form_Current()


'ResumeClickYes

    If Form!NewCalls.Value <> "" Then
 
    Dim otk As Outlook.Application
    Dim eml As Outlook.MailItem
    Dim rs As Recordset
    Dim vMsgString As String
    Dim rsM As Recordset
    
    ' Open your table and build your distribution list
    Set rs = New ADODB.Recordset
    
    With rs
        .Open "tblEMail", CurrentProject.Connection, adOpenKeyset, adLockOptimistic, adCmdTable
        .MoveFirst
        Do While Not .EOF
        Strlist = Strlist & rs.Fields("EMail").Value & ";"
        rs.MoveNext
    Loop
     Set rsM = New ADODB.Recordset
     
     With rsM
        .Open "qryNewCall", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
        
        rsM.MoveFirst
        
        Do While Not .EOF
        
        vMsgString = vMsgString & "CallID: " & rsM![CallID] & ",  " & "CreatedDate: " & rsM![CreatedDate] & ",  " & "Status: " & rsM![Status] & ",  " & _
        "Critical: " & rsM![Critical] & ",  " & "Site: " & rsM![Site] & Chr$(13)

        rsM.MoveNext
        
        Loop
            
            Set otk = CreateObject("Outlook.Application")
            Set eml = otk.CreateItem(olMailItem)
            With eml
                .To = Strlist
                .Subject = "New Calls"
                .Body = "New Calls Have Been Added To The Database." & vbCrLf & vbCrLf & vMsgString
                .Send
                End With
            Set eml = Nothing
            rs.Close
    Set rs = Nothing
    End With
    End With
    otk.Quit
    Set otk = Nothing
    

'SuspendClickYes
    Else
    End
    End If


End Sub
I now have office 2003 installed and whenever i try and run the code i get the following error message

compile error:user-defined type not defined.

any help would be appreciated



Regards

Paul

 
OK, sorted out one problem, Outlook object library was not referenced now it errors on the following line
Code:
Set rs = New ADODB.Recordset



Regards

Paul

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top