Hey loungers!
I have recently got this error when testing an bit of code that creates a snapshot of a report, and attaches it to an email with a message/ address (filled out by entry onto a form)
however, since writing the code, my office suite has been “upgraded” to 2007. (however i still use access 2003 for compatibility reasons!) i used the following code:
Dim OL As Outlook.Application, OI As Outlook.MailItem, OA As Outlook.Attachments Dim dbs As DAO.Database, rst As DAO.Recordset Dim intreply As Integer Dim strEmail(3) Set OL = Outlook.Application [color color="#FFFF00"]Set OI = OL.CreateItem(olMailItem)[/color] 'Create SnapShot DoCmd.RunMacro "McrPulmonaryRehab" 'Create Email OI.Recipients.Add "" & Me.cboto & "" OI.CC = "" & Me.cbocc & "" OI.BCC = "" & Me.cbobcc & "" OI.Subject = "" & Me.txtsubject & "" OI.Body = "" & Me.txtmsg & "" & vbCrLf & vbCrLf & "" & "Downloaded on " & Date Set OA = OI.Attachments OA.Add "\charliedatabasesPulmonary RehabPulmonary Rehab ReportsPulmonaryRehabReport" & "" & Month(Now()) & "" & ".snp", olByValue, 1, "Pulmonary Rehab Data " & Date 'Send Email OI.Send 'Add records into the Audit Table strEmail(1) = Me.cboto.Value strEmail(2) = Me.cbocc.Value strEmail(3) = Me.cbobcc.Value Set rst = dbs.OpenRecordset("tblEmailAudit ") i = 1 Do While i <= 3 rst.AddNew rst!Address = strEmail(i) rst!Date = Now() rst.Update Response = acDataErrAdded i = (i + 1) Loop 'Tidy up rst.Close dbs.Close Set rst = Nothing Set dbs = Nothing
On executing the highlighted line i get the following error "Runtime error 13, Type Mismatch"
As everyone in my office now uses 2007, i have no way of testing this theory, but, am i right in assumign that it is an issue with outlook 2007? I have used this code before, and it worked fine with no problems. the reasoning behind my theory is that the only thing to really change is the installation of office 2007.
if this is the case can i be certain that it would work when i pass it onto the client, who uses office 2003?
Thank you for your time.