Solved

Send Mail Task migrating from DTS to SSIS

Posted on 2009-05-14
2
552 Views
Last Modified: 2013-11-10
I have migrated a package from DTS to SSIS.  The Send Mail Task sends email to an Outlook group. This worked in DTS, but SSIS is asking for actual email addresses.  How can I send to a group?
0
Comment
Question by:nordicgirl
2 Comments
 
LVL 13

Accepted Solution

by:
TommyTupa earned 500 total points
ID: 24451683
Most groups have an email alias for example the SMTP address for example our DL-DBAGroup is DBAAdmins@MyCompany.com.  I then use a script task such as below to send mail.  Here is a discussion on the topic: http://social.msdn.microsoft.com/forums/en-US/sqlintegrationservices/thread/7bde3030-491c-4ab7-ad9e-02ca5abad17b/


Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Imports System.Net.Mail


Public Class ScriptMain

    Public Sub Main()

        Dim mailServer As String = "MyMailServer"
        Dim fromAddress As String = "SQLServerNotification@MyCompany.com"
        Dim toAddress1 As String = "DBAGroup@MyCompany.com"
        Dim toAddress2 As String = "Person@MyCompany.com"
        Dim subject As String = "This is my subject: " & CStr(Today)
        Dim body As String
        Dim fileName As String = "c:\file.csv"


     
            body = "Please find todays file attached. The file contains checks job failures from the previous business

        Dim smtp As New SmtpClient(mailServer)
        Dim message As New MailMessage(fromAddress, toAddress1, subject, body)
        message.To.Add(New MailAddress(toAddress2))

       message.Attachments.Add(New Attachment(fileName))

        smtp.Send(message)


        Dts.TaskResult = Dts.Results.Success


    End Sub
End Class
0
 

Author Closing Comment

by:nordicgirl
ID: 31581503
thank you!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how the fundamental information of how to create a table.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now