Sending E-Mail from SQL 2008 Express

  • Jeff Moden (11/4/2010)


    I have to ask because I just don't know... Hopefully, one of you do. Is CDONTS and sp_OA* available in SQL Server Express?

    Anyone?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Thank you for answer.

    I change path and permissions with a share folder with permission to everyone.

    But no change : mail is sending, we receive it well but without attach file.

    Other idea ?

  • It was changed to a shared path - do you mean a UNC path? Is the path to the file something like this: \\server\folder? If so, then try mapping that to a local drive and try it again.

  • Yes, UNC path. I tried on the server and on my computer. And I tried server/computer name and with IP adress.

    Same problem : mail is sending but without attach file

    And there isn't any error message and I've no idea how debug this process...

  • And you verified the NTFS permissions?

  • yes i did;

    control total to everyone

  • Jeff Moden (11/18/2010)


    Jeff Moden (11/4/2010)


    I have to ask because I just don't know... Hopefully, one of you do. Is CDONTS and sp_OA* available in SQL Server Express?

    Anyone?

    I'm not certain, but I don't think CDONTS will be available. Don't think it'd be part of the install of SQL Server Express, but it *might* be part of the OS install, or might come with Microsoft Office if you've got the right parts installed. You're more likely to have CDOSYS I think, if it's newer version of Windows. In googling a bit it looks like maybe SQL Server Express does have email stuff on the SQL Server side, but the core email components (DLLs) are not included and emailing-related services are disabled and buried.

    Sorry for the waffly answer. 🙂

  • dmbaker (11/19/2010)


    Jeff Moden (11/18/2010)


    Jeff Moden (11/4/2010)


    I have to ask because I just don't know... Hopefully, one of you do. Is CDONTS and sp_OA* available in SQL Server Express?

    Anyone?

    I'm not certain, but I don't think CDONTS will be available. Don't think it'd be part of the install of SQL Server Express, but it *might* be part of the OS install, or might come with Microsoft Office if you've got the right parts installed. You're more likely to have CDOSYS I think, if it's newer version of Windows. In googling a bit it looks like maybe SQL Server Express does have email stuff on the SQL Server side, but the core email components (DLLs) are not included and emailing-related services are disabled and buried.

    Sorry for the waffly answer. 🙂

    I am running 2008 developer, 2005 standard and Express and yes Express comes with the sp_OA just like SQL Server 2008 developer but no CDONTS. The reason those are COM dll which the developer division have depreciated since 2005 version of .NET.

    Kind regards,
    Gift Peddie

  • clement.degroote (11/19/2010)


    yes i did;

    control total to everyone

    If permissions is not the issue it may related to the attachement definition in the code. There are two ways to send attachments with System.net.mail one is to use filesystem or to use the streams both require System.IO Import or Using statement.

    Kind regards,
    Gift Peddie

  • Hello.

    Sorry, but I don't understand. Could you tell me more ?

  • clement.degroote (11/22/2010)


    Hello.

    Sorry, but I don't understand. Could you tell me more ?

    Sure so instead of

    Imports System.Net

    Imports System.Net.Mail

    use the code below instead

    Imports System.Net

    Imports System.Net.Mail

    Imports System.IO

    The later code lets you access the file system or the streams like memory stream which is one of the child classes of the Base Class TextWriter.

    Kind regards,
    Gift Peddie

  • we find issue to our problem. we add content-disposition option on the attachment file property.

    See the code below :

    If Not strAttachments.Equals(String.Empty) Then

    Dim strFile As String

    Dim strAttach() As String = strAttachments.Split(";")

    For Each strFile In strAttach

    Dim Data As Net.Mail.Attachment = New Net.Mail.Attachment(strfile.trim())

    Dim Disposition As Net.Mime.ContentDisposition = Data.ContentDisposition

    Disposition.CreationDate = System.IO.File.GetCreationTime(strfile.trim())

    Disposition.ModificationDate = System.IO.File.GetLastWriteTime(strfile.trim())

    Disposition.ReadDate = System.IO.File.GetLastAccessTime(strfile.trim())

    Mailmsg.Attachments.Add(Data)

    Next

    End If

    It works well; so thanks a lot to everyone for help.

    Very good article and very useful for us.

    king regards

  • I've tried the mail send as described here. Its working great except for the part where line breaks/carriage returns are removed from the body of the message. The way I've tried it so far is the p_SendEmail procedure is called via my procedure where the body of the message is concatenated(formatted with line breaks). The mail and attachments are recieved but the line breaks generated by my procedure gets removed.

    This is how I have generated the linebreaks

    SET @MSG ='Dear All,'

    SET @MSG=@MSG+CHAR(13)+'Executive : ' +@EXECUTIVE

    SET @MSG=@MSG+CHAR(13)

    SET @MSG=@MSG+CHAR(13)+'Start Date : ' +CONVERT(VARCHAR(20),@START_DATE,106)

    SET @MSG=@MSG+CHAR(13)

    SET @MSG=@MSG+CHAR(13)+'End Date : ' +CONVERT(VARCHAR(20),@END_DATE,106)

    Finally I pass @MSG as the body of the mail. When the mail is received all the line breaks/carriage returns are absent. Any idea on what's going wrong? The line breaks work properly when I use SQL Db mail.

    --Replaced CHAR(13) with < /br>. Works fine

  • Any tips on how to make this work with an Open SMTP Server?

  • Do you think would be an answer for the problem (in sql 2008) where, using database mail to send email and attachments when logged on to sql with sql authentication, won't allow sending the attachment unless one has sysadmin permission?

    Here is the books online discussion:

    Database Mail uses the Microsoft Windows security context of the current user to control access to files. 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. Therefore, Database Mail may not be able to attach files from a network share in cases where the command is run from a computer other than the computer that SQL Server runs on.

    Have been googling this for days. No one seems to have solution for this problem other than to use windows authentication or give user greater permission, neither of which, is desirable. thanks for any thoughts on this.

Viewing 15 posts - 31 through 45 (of 54 total)

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