Sending E-Mail from SQL 2008 Express

  • Actually, I wrote an enhanced version that allows for dynamic SMTP servers as well as logging to a SQL table. I'll update the article or send in a new one; should be able to have it out within the next week or so.

  • Therefore, users who are authenticated with SQL Server Authentication cannot attach files using @file_attachments. Windows does not allow SQL Server to provide credentials from a remote computer to another remote computer

    I don’t think it is related because @file_attachment is local variable in SQL Server not related to system.net used for Microsoft SMTP mail. Please check the link below for the system stored procedure that defines attachment file size and related issues, the reason you can use Default for the connection properties but you still need to talk to system admin and Exchange admin.

    http://msdn.microsoft.com/en-us/library/ms191442.aspx

    Kind regards,
    Gift Peddie

  • Brilliantly simple stuff, many thanks!

    This solved an age-old problem for us, and we are highly indebted to people like you that take the time to share your knowledge.

    Once again, thanks! πŸ˜€

  • Thanks

  • <begin>

    Dim strRecip As String

    Dim strTo() As String = recipients.Split(";")

    For Each strRecip In strTo

    MailMsg.To.Add(New MailAddress(strRecip))

    Next

    Instead of looping thru the array have you considered something like String.Join(",", strTo) ?

    This allows you to let MS manage the looping and also inserts the comma between names. Since you Split(";") I wonder if it might be easier/quicker to recipients.Replace(";", ",") and thus no need for the array to begin with and you now have a comma separated list that the Address collection is looking for?

    Cool function and thanks for a good demo of making a clr function for SQL Server.

  • Passing in a comma separated list of recipients is good and well if you were hard-coding them, but it would become more work if it were queried from a table. I'd imagine that you could pass in a table variable to be consumed as a DataTable instead. I've done this with a C# app., but not with an extended stored procedure.

  • Great article, but I don't understand why you would go thru all this trouble, not to mention opening up CLR on the server, which is a security risk if not handled correctly, when all you need to do is execute sp_send_dbmail (just like on a regular standard or enterprise install of SQL)?

  • Nice solution - just wondering why you wouldn't simply use DBMail?

  • Nice to read.......

    thinking in a new way πŸ™‚

  • Excellent stuff. I have managed to get it working on a new SQL Express 2016 server.

Viewing 10 posts - 46 through 54 (of 54 total)

You must be logged in to reply to this topic. Login to reply