paul.hartland at fsmail.net
paul.hartland at fsmail.net
Tue Jul 1 05:13:05 CDT 2003
To all, I have a VB6 FE connecting to a SQL Server 7.0 BE using a very simple personnel form (payroll number, address etc). When a user changes a payroll number I want to send an email to HR, but also CC to IT Programmers. I have a data environment with a recordset looking at tblUsers which has their email addresses and deptartment or job title in. I am using the code below but I get the error message something like 'invalid recipients', but if I just enter my name as normal in the CC (i.e. Paul Hartland) then it works fine, if I try and pick it from the recordset the error message occurs again, even though my name in the database is Paul Hartland ???...Can anyone see anything wrong with the code below..........Watch for wrapping....... If (DEGenSQL.rstblUsers.State = adStateOpen) Then DEGenSQL.rstblUsers.Close End If DEGenSQL.tblUsers pubEmailSub = "" pubEmailBody = "" MAPISession1.SignOn MAPIMessages1.MsgIndex = -1 MAPIMessages1.RecipType = 1 With DEGenSQL.rstblUsers .MoveFirst Do Until (.EOF) If (.Fields("DeptOrJob") = "HR") Then MAPIMessages1.RecipDisplayName = .Fields("EmailAddress") MAPIMessages1.RecipIndex = MAPIMessages1.RecipCount End If .MoveNext Loop .MoveFirst MAPIMessages1.RecipType = 2 Do Until (.EOF) If (.Fields("DeptOrJob") = "IT Programmer") Then MAPIMessages1.RecipDisplayName = .Fields("EmailAddress") MAPIMessages1.RecipIndex = MAPIMessages1.RecipCount End If .MoveNext Loop End With DEGenSQL.rstblUsers.Close pubEmailSub = "**** THIS IS A TEST - PLEASE DELETE THIS EMAIL ****" 'pubEmailSub = "Payroll Number has been Changed" pubEmailBody = Payroll number changed MAPIMessages1.MsgSubject = pubEmailSub MAPIMessages1.MsgNoteText = pubEmailBody MAPIMessages1.SessionID = MAPISession1.SessionID MAPIMessages1.Send False MAPISession1.SignOff Thanks in advance for any help...... Paul Hartland __________________________________________________________________________ Join Freeserve http://www.freeserve.com/time/ Winner of the 2003 Internet Service Providers' Association awards for Best Unmetered ISP and Best Consumer Application. _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com