Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Sending email and setting calendar from trigger Expand / Collapse
Author
Message
Posted Wednesday, November 10, 2010 5:09 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, November 30, 2010 5:01 AM
Points: 2, Visits: 10
Hi

I want to create a trigger in my Absence table so when an absence inserted, it sends an email to the employee and set the absence type reminder in his outlook calendar.

Would you please help me?

Thanks
Post #1018493
Posted Wednesday, November 10, 2010 6:24 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, December 13, 2013 4:35 AM
Points: 386, Visits: 211
I wouldn't do this in a trigger.
Use the trigger to insert into a table then have a scheduled job which polls the table and does the processing when an entry appears.

In that way you have a record of what's been processed and done hold up/error the system due to email issues.



Cursors never.
DTS - only when needed and never to control.
Post #1018531
Posted Wednesday, November 10, 2010 7:34 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, November 30, 2010 5:01 AM
Points: 2, Visits: 10
Thanks SSC

But I still do not know how to write the code to make the calendar reminder on the day of absence
Post #1018610
Posted Wednesday, November 10, 2010 9:20 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Yesterday @ 4:38 PM
Points: 31,018, Visits: 15,453
You will have to look up the format for a calendar entry. This isn't a SQL issue, but rather a mail construction issue. Once you have that, you can construct that and attach it to the mail message.






Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1018730
Posted Wednesday, November 10, 2010 9:22 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Friday, August 1, 2014 6:18 AM
Points: 1,618, Visits: 20,980
These examples should get you started.

http://blog.netnerds.net/2008/02/create-a-basic-sql-server-2005-trigger-to-send-e-mail-alerts/

http://www.datasprings.com/Resources/ArticlesInformation/CreatingEmailTriggersinSQLServer2005.aspx


Pradeep Adiga
Blog: sqldbadiaries.com
Twitter: @pradeepadiga
Post #1018732
Posted Wednesday, November 10, 2010 10:23 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 4:43 AM
Points: 12,895, Visits: 32,090
i thought this was interesting; from what i read on the Wikipedia you have to create a plain text attachment, with specific tags/formats inside that file, and the name of the file ends in .ics

so you have to create a file as an attachment, and then attach it to the email you were going to send. outlook /thunderbird/whatever mail program which can handle the iCalendar format will interpret the file accordingly.


Lowell

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1018793
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse