Hi i have a script that creates an email for weekend bookings confirmation for musicians. it works perfectly on my computer and worked fine on my other computer till just recently and now it brings up error "13" when i try and run the object?
the code is as follows and seems to be an issue when it actions the outlook.
i just dont understand why it works on mine and not the other computer? please help. it errors on the line Set objMailItem = objOutlook.CreateItem(olMailItem)
:banghead:
the code is as follows and seems to be an issue when it actions the outlook.
i just dont understand why it works on mine and not the other computer? please help. it errors on the line Set objMailItem = objOutlook.CreateItem(olMailItem)
:banghead:
Code:
Private Sub Command234_Click()
Dim msgTxt As Variant
Dim objOutlook As Outlook.Application
Dim objMailItem As Outlook.MailItem
Dim blnCreated As Boolean
Dim act As String
Dim venue As String
Dim start As String
Dim finish As String
Dim venuefee As String
Dim bookingfee As String
Dim venuepayment As String
Dim gigdate As String
Dim venue_email As String
strEmail = "bookings@gigs.com"
strSubject = "New Booking Confirmation - "
strBody = "<h2><b>A new booking has been confirmed</b></h2>"
act = Me.artist
gigdate = Format(Me.gigdate, "dddd dd mmmm yyyy")
venue = Me.venuename
start = Format(Me.start, "hh:nn am/pm")
finish = Format(Me.finish, "hh:nn am/pm")
venuefee = Me.venuefee
bookingfee = Me.bookingfee
commission = Me.commission
venuepayment = Me.venuepayment
taken = Me.takendate
venue_email = Me.venue_email
blnCreated = False
Set objOutlook = New Outlook.Application
If IsNull(Me.venue_email) = True Or Me.venue_email = "" Then
DoCmd.Hourglass False
msgTxt = MsgBox("Unable to create an email for " & Me.act & Chr(13) & "No email address listed in the database.", vbOKOnly + vbInformation, "")
Else
DoCmd.Hourglass True
[B]Set objMailItem = objOutlook.CreateItem(olMailItem)[/B]
With objMailItem
.To = Me.venue_email
.CC = strEmail
.Subject = strSubject & " " & venue & " on " & gigdate & " - " & act
.HTMLBody = strBody & "<p>" & "<p>" & act & "<br>" & gigdate & "<br>" & venue & "<br>" & start & " - " & finish & "<br>" & "$" & venuefee & "<p>" & "Payment Details: " & venuepayment & "<p>" & "Please reply OK to confirm this booking"
.Save
' .Send
blnCreated = True
End With
End If
If blnCreated Then
msgTxt = MsgBox("Finished creating email. The email is in your Outlook 'Drafts' folder.", vbOKOnly, "")
Else
msgTxt = MsgBox("Email Failed.", vbOKOnly, "")
End If
DoCmd.Hourglass False
End Sub