Tracey writes "I get the following error error [ODBC error 170 (42000) Line 1: Incorrect syntax near 'Dingleberry'.] when adding the subject parameter to xp_sendmail. If I just leave the default subject line, it works fine.I would appreciate any help with this frustrating problem.Here is my code:*****************************************************************Fetch Next From EmailCursor Into @employeeid, @email, @Classname, @Classdate, @Location, @ClassId, @SessionId While @@Fetch_Status = 0Begin set @apostrophe = ''' set @position = CHARINDEX(@apostrophe,@className,0) IF @position > 1 BEGIN set @position = @position -1 set @classname = LEFT(@classname, @position) + ''' ' + Right(@classname, @position+6) END print @employeeID print @classname Select @message = 'Reminder: ' + @Classname + ' will start on ' + convert(varchar(11), @Classdate) + ' at ' + @Location + '.' If Not Exists (Select * from tblMail_Log Where EmployeeId=@EmployeeId and ClassId=@ClassId and SessionId=@Sessionid) Begin set @subject = 'Class Notification' --print @subject --print @message Select @CurrentDate = getdate() exec master.dbo.xp_sendmail @email, @subject, @message if @@Error = 0 exec usp_Mail_Insert_Log @EmployeeId, @ClassId, @Sessionid, @CurrentDate End Fetch Next From EmailCursor Into @employeeid, @email, @Classname, @Classdate, @Location, @ClassId, @SessionId End
*****************************************************************"