Hello Everybody,
I have a database that on_click, generates a .rtf file, opens up outlook, and sends it to all senders whose address exists within a table –all borrowed from http://www.jephens.com/2007/05/13/ho...using-outlook/. Code is as follows;
Unfortunately, our IT has upgraded us from Outlook 2003 to Outlook 2007 and I am getting a debug error 287 on the lineCode:Option Compare Database Option Explicit Public Function SendEMail() Dim db As DAO.Database Dim MailList As DAO.Recordset Dim MyOutlook As Outlook.Application Dim MyMail As Outlook.MailItem Dim Subjectline As String Dim BodyFile As String Dim fso As FileSystemObject Dim MyBody As TextStream Dim MyBodyText As String Dim stDocName As String Set fso = New FileSystemObject Subjectline$ = "BreachAlert" MyBodyText = "Blahblahblah" If 1 = 2 Then BodyFile$ = "InputBox" Set MyBody = fso.OpenTextFile(BodyFile, ForReading, False, TristateUseDefault) MyBodyText = MyBody.ReadAll MyBody.Close End If Set MyOutlook = New Outlook.Application Set db = CurrentDb() Set MailList = db.OpenRecordset("MyEmailAddresses") Dim MyRecip As Outlook.Recipient Do Until MailList.EOF Set MyMail = MyOutlook.CreateItem(olMailItem) 'MyMail.To = MailList("email") Set MyRecip = MyMail.Recipients.Add(MailList("email")) MyRecip.Type = olBCC MyMail.Subject = Subjectline$ MyMail.Attachments.Add "I:\CYTLAB\Breach\Breach.rtf", olByValue, 1, "My Displayname" Dim MyQuery As QueryDef Set MyQuery = CurrentDb.QueryDefs("ReportSource") MyQuery.SQL = "select * from emails " MyQuery.Close MyMail.Send MailList.MoveNext Loop Set MyMail = Nothing MyOutlook.Quit Set MyOutlook = Nothing MailList.Close Set MailList = Nothing db.Close Set db = Nothing End Function
I have tried googling for answers but to no avail. Can anyone see what I need to do? Any pointers very gratefully received.Code:Set MyRecip = MyMail.Recipients.Add(MailList("email"))
Mattbro