locked
how to email a ssrs report RRS feed

  • Question

  • User-1232439801 posted

    hi..
    i'm using ssrs 2008 enterprice edition..
    i want to send a report as email..
    to my gmail address.. i want to schedule a report so that it can
    deliver daily to my gmail address..

    how to send the report to my gmail address..
    i dont know anything about smtp server activation and services
    and also in configuration of reporting services..
    i dont know how to configure email settings..

    please help me..
    can anyone provide a step by step datails
    for the above requirment..
     

    Tuesday, February 1, 2011 7:59 AM

Answers

  • User1478985342 posted

    'Since emails allow for HTML content, teh first step is to generate a string that will represent the body of the email, so once you get the information from the database, feed it into a semi-nicely-formatted string (probably just a simple table)

    Adding the following string to your web.config file (you can also configure this from IIS) at the end inside the <configuration> tag: What this does is enables an email address to send an email - so you could send it to yourself, technically. If you're using gmail you'll probably need to configure the "port" and might need to enable SSL as well - check Google's Help links for configuring an email client to find the technical details.

    <system.net>
    <
    mailSettings>
    <
    smtp>
    <
    network defaultCredentials="false" password="password" userName="youremailhere" port="25" />
    </
    smtp>
    </
    mailSettings>
    </
    system.net>

    To actually send the email from code, just:

    Dim sc As New SmtpClient()

    Dim mm As New MailMessage()

    sc.Host = "yourhosthere" 'probably smtp.gmail.com

    sc.Port = 25 'i think with gmail the port is like 445? not sure, better check the doc, also, you may need to do sc.enableSSL, but i think if you've got all this stuff configured in your web.config file, you don't need it here.

    mm.From = New MailAddress(youremail@email.ext)

    mm.To.Add(recip)

    mm.Subject = subject

    mm.IsBodyHtml = True

    mm.Body = body

    sc.Send(mm)

    Hope this helps! Sorry if it's confusing at points - just let me know and i'll try to clear it up. I pretty much just copied the code i used for my application.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 2, 2011 11:08 AM