How to send set of emails from SSIS

Hi All,
I would like to send set of emails from SSIS.
For eg: I have to,from,Subject and mail body present in a table. I would like to go through the table 1 row at a time and send mails
Regards,
P M-S

Hi Vishal,
Thanks for the response.
Example doesn't say how to dynamically control To and From lines. What I am looking for is to send mails from an existing table which has To,From,Subject and Body. Basically 1 email per row from an existing table
regards,
P M-S
You can do this in T - SQL itself using sp_send_dbmail
the code will look like below
IF OBJECT_ID('tempdb..#temp') IS NOT NULL
DROP TABLE #temp
SELECT *,
ROW_NUMBER() OVER (ORDER BY PK) AS ID
INTO #temp
FROM Yourtable
DECLARE @ID int,@To varchar(5000),@From varchar(5000),@Subject varchar(max)
SELECT TOP 1 @ID = ID,
@To = To,
@From = From,
@Subject = Subject
FROM #temp
ORDER BY ID
WHILE @ID IS NOT NULL
BEGIN
EXEC sp_send_dbmail @recipients = @To,
@from_address = @From,
@subject = @Subject
SELECT TOP 1 @ID = ID,
@To = To,
@From = From,
@Subject = Subject
FROM #temp
WHERE ID > @ID
ORDER BY ID
END
Assuming you've default private mail profile set or there's a public profile defined for msdb
otherwise you need to pass a valid mail profile
IF in SSIS you can do this
https://support.microsoft.com/kb/906547?wa=wsignin1.0
http://www.devtechie.com/post/2013/01/04/Send-Mail-Task-%E2%80%93-Dynamic-Recipient.aspx
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page

Similar Messages

  • How to send PLAIN text email from sp_send_dbmail using SQL Server 2008 R2?

    I have configured Database Mail in SQL Server 2008 R2 (64) and it sends emails just fine. However the destination is recieving the body of thes message as Base 64 encoding.
    Snippet:
    EXEC msdb..sp_send_dbmail @profile_name='Outmail', @recipients = @recpts, @subject = @subj, @body_format = 'TEXT', @body=@body2;
    As you can see I set @body_format to TEXT, but it still sends Base 64. I need to send plain ASCII text. How can I change this?

    I am having this exact issue too.  I have a trigger that sends an email using a stored procedure.  The dbmail is sending the email using the Exchange 2010 server SMTP.  It does not login so the email is relayed as user = "Anonymous". 
    The SQL dbmail email header is showing the following:
    Content-Type: text/plain; charset="utf-8"
    Content-Transfer-Encoding: base64
    MIME-Version: 1.0
    X-MS-Exchange-Organization-AuthSource: MX01.domain.local
    X-MS-Exchange-Organization-AuthAs: Anonymous
    Here is the header if I send via Outlook profile using the legacy program I am trying to automate using SQL Server 2008R2:
    Content-Type: application/ms-tnef; name="winmail.dat"
    Content-Transfer-Encoding: binary
    MIME-Version: 1.0
    X-MS-Has-Attach:
    X-MS-Exchange-Organization-SCL: -1
    X-MS-TNEF-Correlator: <[email protected]>
    MIME-Version: 1.0
    X-MS-Exchange-Organization-AuthSource: MX01.domain.local
    X-MS-Exchange-Organization-AuthAs: Internal
    X-MS-Exchange-Organization-AuthMechanism: 03
    X-Originating-IP: [192.168.13.66]
    Any help would be greatly appreciated!

  • How to Send Foreign Language Email from the iPhone

    See this site for online keyboards for some other languages which can be used to generate a mail message from the iPhone.
    http://pointatme.com/keyboards/keyboard.html

    The keyboard included in the current version of the iPhone is limited to English. But at this site you will find online keyboards for some European languages which can be used to generate a mail message from the iPhone.
    http://pointatme.com/keyboards/
    And if you point the iPhone browser to this page you can send email in Japanese:
    http://n.h7a.org/iphone/mail/

  • How do I set an email to send at a specific time/date in the future e.g. tomorrow at 9am. I am on an iMACX using apple's version of windows

    how do I set an email to send at a specific time/date in the future e.g. tomorrow at 9am. I am on an iMAC using apple's version of windows

    apple don't have a version of windows
    only microsoft have windows
    as how one automatate windows to send mails at a time
    googled it for you
    http://www.howtogeek.com/125045/how-to-easily-send-emails-from-the-windows-task- scheduler/
    more options in the search
    https://www.google.dk/search?client=opera&q=automatically+send+email+in+windows& sourceid=opera&ie=UTF-8&oe=UTF-8

  • How do I Set up email acc so I can receive emails from another property

    I have 2 homes and both have Broadband but with different providers (talktalk and tiscali). I have just move to Apple from Windows. With Mac mail I don't seem to be able to set up an account to read the emails from the property that does not have that provider. So house A has provider A and house B provider B. Windows allowed me at house A to to send and receive emails from provider A and read emails from provider B. At house B I could send and receive B emails and only receive A emails. I want to do the same with my Mac. How do I do this as when I go through the set up accounts process it seems to force me to register both the POP3 and SMTP for A and B and when it cannot find the outgoing server (in this case B when I am at house A). With windows it allowed you to set them both up at both houses because it did not perform a check as you set the accounts up.

    Nigel
    Welcome to the Apple user discussion forums
    I have 2 homes and both have Broadband but with different providers (talktalk and tiscali). I have just move to Apple from Windows. With Mac mail I don't seem to be able to set up an account to read the emails from the property that does not have that provider. So house A has provider A and house B provider B. Windows allowed me at house A to to send and receive emails from provider A and read emails from provider B. At house B I could send and receive B emails and only receive A emails. I want to do the same with my Mac. How do I do this as when I go through the set up accounts process it seems to force me to register both the POP3 and SMTP for A and B and when it cannot find the outgoing server (in this case B when I am at house A). With windows it allowed you to set them both up at both houses because it did not perform a check as you set the accounts up.
    I do not understand your problem or your question
    In general what I have found is that some (many?) internet providers will not allow you to sent e-mail if you are not on their network but there is no problem receiving e-mail
    I have two houses A & B and internet providers A & B but my e-mail provider is a separate company, provider C, I find the following:
    I can receive mail from C via POP3 from both houses A & B
    In both houses I am unable to sent mail using SMTP using provider C but must use the local internet provider, provider A for house A and provider B
    If you have e-mail accounts at both A & B you should be able to set up two accounts, one for provider A and one for provider B - both would use POP3 to receive mail and should work from either house - each would use its own SMTP service - A for house A and B for house B - If you want to send mail from account A in house B you would have to change the outgoing SMTP server while you are there and change it back when you go to house A - same for sending mail from account B while in house A
    Maybe this helps - if not try asking again and maybe I'll get it beter next time
    LN
    Message was edited by: LarryHN

  • How do I set up email accounts to send emails while travelling overseas using various wifi locations?

    How do I set up email accounts to send and receive
    emails while travelling overseas using various wifi locations?

    Many ISP provided email accounts limit connections to their outgoing SMTP email servers to only connections coming from their own network. So, if you try to send email when not connected to their network (i.e. when not at home), the connection will be rejected.
    If you are using an ISP provided email address, in these circumstances, you'll need to ask your ISP if they provide an "authenticated SMTP connection" so that you can send email via their SMTP server when not actually accessing the internet via their network. You'll need to enter your email account username and password in the Outgoing SMTP server settings and possible configure SSL or outgoing port numbers. Your ISP will be able to advise on this though, as the exact setting vary between ISPs.
    By far the best solution though, is to use an email account that is not tied to any particular ISP, such as a GMail account, as these can be used from anywhere, on any network and provide authenticated SMTP as standard.

  • How can I send pictures or email from my desktop to a cell phone?

    How can I send pictures or email from my desktop to a cell phone?
    I use Gmail for my emails.

    By sharing playlists you mean sending the list of song titles along with the songs themselves you can't.  That would violate Apple's contracts with the studios regarding sharing music, videos, books, etc.  Which is strictly forbidden. With the single exception that I am aware of which is Home Sharing.
    If you just want to share the list of song titles you could take a screen shot and email that.  Hold down the home button and press and release the power button.  The image is then stored in your camera roll.

  • How do i set up email address to print from iphone?

    how do i set up email address so i can print from my iphone into my wireless printer?

    Which printer do you have?
    I was an HP employee
    If I have helped you solve your issue please mark it as solved
    **Say Thanks By Clicking on the Kudos Star**

  • How do I send a group email from Droid MAXX Gmail android app?

    I have multiple groups setup in PEOPLE. How do I send a group email from my GMAIL app?

        glenholmes,
    You've come to the right place for help. Sorry to hear that you have had hard time with your Gmail app lately. What steps have you tried to get this to work? We want to ensure that you are able to start sending those messages right away.
    ErinW_VZW
    Follow us on Twitter @VZWSupport

  • How do I send attachments by email from my iPad

    How do I send attachments by email from my iPad

    The thing to remember is that iOS email attachments start with the document itself, not from the Mail app.
    1. Select the thing you want to send in an app that handles it, (for example a Photo might be sent from Photos, a PDF from GoodReader etc.)
    2. Then tap the "share" button (which I see others have kindly posted screenshots for) and create an email containing that attachment.
    Peter
    <Link Edited By Host>

  • How do I set up email addresses from my address book?

    How do I set up email addresses from my address book?

    I'm not sure exactly what you are asking.  If you are coming from pre-Mountain Lion, then Address Book has changed to Contacts.
    Open Contacts.
    Select an Account in the group list, if you want the contact in a specific group. If Groups aren't showing, you can display them from the View menu.
    Click the Add card button ( + ).
    Enter the information for the contact.
    If you need multiple entries for a particular field type, a new blank entry will show up below the one you are adding.
    If you need other fields, use the Card menu to Add a new field type.
    If you want to change the default fields available when you create a new card, choose Edit Template…
    If you have sent emails to someone and you want to get that address to add to a Contact, use the Previous Recipients command in the View menu in Mail.
    If you need to add a new Group, hover the cursor over the account name, and a + button will appear. Click it.

  • Can I send a delayed email from an iPad? if so, how?

    How can I send a delayed email from my iPad?

    The only way would be to draft the E-mail and then close the iPad.  A draft would be created that would, I think, be sent the next time you turn the iPad on.
    There is no "time delay" function.
    Barry

  • How can a send a group email from ipad

    How can I send a group email from iPad

    You need a third party app. You can't create contacts groups in the built in mail app. Look at...
    http://solubleapps.com/mailshot/
    or
    http://www.redbits.com/iphone/groupemail/

  • How do i send a html email from office outlook web access?

    how do i send a html email from office outlook web access?

        glenholmes,
    You've come to the right place for help. Sorry to hear that you have had hard time with your Gmail app lately. What steps have you tried to get this to work? We want to ensure that you are able to start sending those messages right away.
    ErinW_VZW
    Follow us on Twitter @VZWSupport

  • How can I set up email on iphone 5 to leave emails on the server if I delete them from iphone?

    How can I set up email on iphone 5 to leave emails on the server if I delete them from iphone?

    Hi RK GARG,
    Welcome to the Support Communities!
    The article below will explain how to access the Advanced settings in your email account.
    Click on the link to see screen shots.
    To answer your question ... change the Deleted Messages -  Remove field to Never
    Using a POP account with multiple devices
    http://support.apple.com/kb/HT3228
    In Settings, select Mail, Contacts, Calendars.
    Select the account for which you wish to change the settings.
    Select Advanced, located at the bottom of the list.
    Cheers,
    - Judy

Maybe you are looking for