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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting compile error cannot find project or library.

Status
Not open for further replies.

Sheena2

Programmer
Apr 18, 2008
9
CA


Hello I need help as the system is not recognising (olMailIt) could some one check my code and assist me as I am fairly new at this. Thanks for your asistance

Private Sub SendInTouchToAdmin_Click()
On Error GoTo Err_SendInTouchtoAdmin_Click
Dim myolApp As Object
Set myolApp = CreateObject("Outlook.Application")
Me.RecordSource = "qry_InTouchAdmin"
Set objMailItem = myolApp.CreateItem(olMailIt)
With objMailItem
.Recipients.Add Me!SendTo
.Subject = Me!Subject
.Body = Me!Body
.Attachments.Add "" & Me!Attachment
.Send
End With
Me.Recordset.MoveNext
Set objMailItem = oApp.CreateItem(olMailItem)
With objMailItem
.Recipients.Add Me!SendTo
.Subject = Me!Subject
.Body = Me!Body
.Attachments.Add "" & Me!Attachment
.Send
End With

MsgBox "In Touch E-Mail Sent to Administrator"
Exit_SendInTouchtoAdmin_Click:
Exit Sub

Err_SendInTouchtoAdmin_Click:
MsgBox Err.Description
Resume Exit_SendInTouchtoAdmin_Click
End Sub

Private Sub SendInTouchtoCongregations_Click()
On Error GoTo Err_SendInTouchtoCongregations_Click
Dim oApp As Object

Set oApp = CreateObject("Outlook.Application")
Me.RecordSource = "qry_InTouch"
Me.Recordset.MoveFirst
Do Until Me.Recordset.EOF
Set objMailItem = oApp.CreateItem(olMailItem)
With objMailItem
.Recipients.Add Me!SendTo
.Subject = Me!Subject
.Body = Me!Body
.Attachments.Add "" & Me!Attachment
.Send
End With
Me.Recordset.MoveNext
Loop
MsgBox "In Touch E-Mail Sent to Congregations"
Exit_SendInTouchtoCongregations_Click:
 
You need to check the missing project reference (probably an Outlook library). Go to the VB IDE and click on Tools|References. If there are any tagged as "missing", check them. Hopefully someone knows the lib you need; I would start out with one of the CDO libs first & see if that resolves your error.

"Artificial Intelligence is no match for Natural Stupidity"
 
Replace this:
olMailIt
with this:
olMailItem

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks for all your help. I did the changes and it works now. Have a nice day
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top