locked
Sending email using MSSQL Express RRS feed

  • Question

  • User-1901014284 posted

    Hi,

    I have a stored procedure which pulls records from multiple tables by using the clientID when the user signs into their system, the records pulled from the database are then made visible on their client on their portal, what I would now like to do is send these records to the relevant users by using the clientID within the login table and the tables in which the data has been pulled from?

    Any help would be greatly appreciated.

    Thanks

    Jonny

    Wednesday, May 22, 2019 2:57 PM

All replies

  • User753101303 posted

    Hi,

    Not sure which kind of help you are looking for (as it seems you already know you could send emails direclty from SQL Server ?).

    Are you looking for the https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-send-dbmail-transact-sql?view=sql-server-2017 stored procedure ? It needs to be configured first (see the general "Database mail" link at the bottom of this page).

    If it doesn't help please be more explicit about the very first problem you have when trying to do so (another option is still to send a mail from the web server).

    Edit:: according to https://social.msdn.microsoft.com/Forums/sqlserver/en-US/cd59b9cc-21ea-4130-afd1-791124031ada/can-sql-server-express-send-emails?forum=sqlexpress it seems it was not yet available in SQL Server Express 2014. Which version do you use ? If confirmed for later version your "best" option could be to send this mail from the web server.

    Edit 2 : according to https://www.veryiz.com/2017/configure-sql-database-email/ it is available in SQL Server Express 2012 but you don't have a GUI for some steps (but it could be also outdated now that we don't have any more a special version of SSMS for SQL Express).

    Wednesday, May 22, 2019 3:11 PM
  • User-1038772411 posted

    Hi, jonnygareth30

    Please Refer below link it will help you find out how will send email using MSSQL Express

    https://expressdb.io/sql-server-express-sp-send-dbmail/

    Also Refer below link which give you step by step solutions

    http://www.sqlservercentral.com/blogs/querying-microsoft-sql-server/2013/09/02/sending-mail-using-sql-server-express-edition/

    Thanks.

    Tuesday, May 28, 2019 12:52 PM
  • User61956409 posted

    Hi Jonny,

    jonnygareth30

    I have a stored procedure which pulls records from multiple tables by using the clientID when the user signs into their system, the records pulled from the database are then made visible on their client on their portal, what I would now like to do is send these records to the relevant users by using the clientID within the login table and the tables in which the data has been pulled from?

    According to your description, we can know that the your application would retrieve the data from database based on clientID and display the retrieved data on portal after user signed into the system, to send email to specific users, you can also achieve it in your application logic, and which would be easy to implement complex and flexible sending email functionality. For example, you can execute/trigger a background task to send emails after you rendered portal with the returned data.

    With Regards,

    Fei Han

    Wednesday, May 29, 2019 6:58 AM
  • User-1901014284 posted

    Thank you all for your replies, unfortunately having followed some of the provided links emails are created by are then qued and never sent. I have been looking into Quartz and wondering if and how a stored procedure could be called and sent using the scheduling with Quartz within ASP.NET C#?

    Within the system I have built in email functions which run on button clicks.

    Again many thanks for all your help and again any assistance is greatly appreciated.

    Many thanks

    Jonny

    Tuesday, June 4, 2019 1:52 PM
  • User753101303 posted

    For now it doesn't seems it would solve your problem anyway (Quartz is to schedule work but it seems your intent is still to call a SP that sends this mail ?)

    IMO it is always bad to just try something else because what you tried first doesn't. Understand first if is supposed to work and understand why it doesn't ?

    Which SQL Server Express version are you using ? You configured a SMTP server  to which queued mails could be sent ? You won't be able to send mails with SQL Server alone. It needs to be configured to forward those mails to a mail server.

    Tuesday, June 4, 2019 2:37 PM