Sending Tmail to External Mail
Looking for a way to notify users that they have a Tmail message to review without relying on them to log into TIER®? Try sending notifications to your external email instead.Xp_sendmail is a SQL system stored procedure that uses SQL Mail to send notifications to external email systems. This stored procedure runs against the master database and can be called from within another stored procedure or a trigger on a table. Below is a sample trigger that can be applied to your SQL Tmail table. When new Tmail messages are created, they are inserted into the table TMB_Messages and this particular trigger will send a mail notification upon insertion. Note: you may have to change your user’s SQL permissions so that they can run the sendmail stored procedure from TIER®. CREATE TRIGGER [dbo].[TRG_TMB_Messages_New]ON [dbo].[TMB_Messages]FOR INSERT ASSet Nocount on-- declare table variables Declare @Topic varchar (100) Declare @MsgKey int declare @body2 varchar(2000) -- holds the body of the emaildeclare @Subject2 varchar(25) -- holds the mail subjectdeclare @eMailID varchar(50) -- holds the email id-- gets the data from the newly inserted itemSELECT @Topic = Topic, @MsgKey = MsgKeyFROM Inserted-- join inserted data on other tables to get additional info neededselect @emailID = email from tmb_Messages inner join tmb_msgrecipients on tmb_messages.msgkey = tmb_msgrecipients.msgkeyinner join fd__staff on fd__staff.staffkey= tmb_msgrecipients.recipkey where tmb_messages.msgkey = @msgkeySET @Subject2 = 'TMail Message Received'SET @body2 = 'You have received a Tmail message regarding ' + @topic + '. Please log into the Sequest database to read this important message.'+ char(10) + char(13) + 'Tier Administrator' + char(10) --xp_sendmail is the extended sproc used to send the mail messageEXEC master..xp_sendmail@recipients = @eMailID,@subject = @Subject2 ,@message = @body2Please contact your network administrator and/or database administrator for more information on how to implement this. Note: This procedure may not be supported in SQL versions higher than SQL2000. If you are looking at making a SQL Server switch in the near future, Database Mail is suggested instead (sp_send_dbmail). Please refer to your SQL documentation for instructions on how to do this.
