Page 1 of 1

SMTP setting in web.configs

Posted: Thu Oct 11, 2018 3:57 pm
by JohnW
I would like to place my SMTP mail settings into the web.config file. If I do, will the Stimulsoft email report process still work? Are there other things I would need to change to make this work?

Thanks

John W

Re: SMTP setting in web.configs

Posted: Fri Oct 12, 2018 2:40 pm
by Lech Kulikowski
Hello,

Could you explain your issue in more details? Also, please clarify which product and version are you use?

Thank you.

Re: SMTP setting in web.configs

Posted: Sat Oct 13, 2018 3:18 pm
by JohnW
I am using the latest version of Stimulsoft Reports. I currently have the SMTP settings for mailing the reports Z(url, login, password, etc) set in the code for the EmailReport call.

I would like to move those settings to the web.config for ease of future maintenance. For example, the client moves to another SMTP provider. It will simplify those types of changes. I just want to make sure the email process with see the settings in the web.config.

Re: SMTP setting in web.configs

Posted: Sun Oct 14, 2018 2:16 pm
by JohnW
This is an example of how I do it in other applications with SSRS reporting. This code sits in the web.config

Code: Select all


  <system.net>
    <mailSettings>
      <smtp deliveryMethod="Network" from="xxxxx@xxxxxx.us">
        <network host="smtp.xxxxxx.com" password="xxxxxxxxxx" port="25" userName="xxxxxx"/>
      </smtp>
    </mailSettings>
  </system.net>
  
  

Re: SMTP setting in web.configs

Posted: Wed Oct 17, 2018 7:07 am
by Lech Kulikowski
Hello,

It is not supported email via web.config

Please check the following article:
https://www.stimulsoft.com/en/documenta ... _email.htm

Thank you.

Re: SMTP setting in web.configs

Posted: Wed Oct 17, 2018 2:22 pm
by JohnW
That is the way I have it set now. Perhaps a future release could support SMTP settings in the web.config. It makes maintenance easier for reporting applications.

Thanks

John W

Re: SMTP setting in web.configs

Posted: Wed Oct 17, 2018 3:22 pm
by JohnW
I decided to experiment. Here is the VB code that reads SMTP settiings from the web.config. For me it helps with post deployment maintenance. If you improve on it -please share the code.

Thanks

John W.

Code: Select all


Place in Web.Config  SMTP settings (After system.web section)



 <system.net>
    <mailSettings>
      <smtp deliveryMethod="Network" from="xxxxxxxo@xxxxxxx.us">
        <network
		host="smtp.xxxxxx.com"
		port="25"
		userName="serverxxxxxx"
		password="xxxxxxxxx" />
      </smtp>
    </mailSettings>
  </system.net>

*************************************************************  
 Protected Sub StiWebViewer1_EmailReport(sender As Object, e As StiEmailReportEventArgs) Handles StiWebViewer1.EmailReport

	Dim format As StiExportFormat = e.Format
        Dim report As StiReport = e.Report
        Dim settings As StiExportSettings = e.Settings
        Dim options As StiEmailOptions = e.Options

'Read SMTP settings from web.config

        Dim section As SmtpSection = CType(ConfigurationManager.GetSection("system.net/mailSettings/smtp"), SmtpSection)
        Dim from As String = section.From
        Dim host As String = section.Network.Host
        Dim port As Integer = section.Network.Port
        Dim enableSsl As Boolean = section.Network.EnableSsl
        Dim user As String = section.Network.UserName
        Dim password As String = section.Network.Password
     
        Try
           
            options.AddressFrom = from
            options.Host = host          
            options.Port = port
            options.UserName = user
            options.Password = password
            options.EnableSsl = False

        Catch ex As Exception
            Dim strmsg As String = ex.Message

        End Try

End Sub]

Re: SMTP setting in web.configs

Posted: Sat Oct 20, 2018 9:06 am
by HighAley
Hello, John.

We will discuss your request with our team and will let you know about our decision.

Thank you.

Ticket reference: #7215

Re: SMTP setting in web.configs

Posted: Sat Oct 20, 2018 4:16 pm
by JohnW
Using the code I provided works. I would think a there must be a cleaner way to implement it.

Re: SMTP setting in web.configs

Posted: Mon Oct 22, 2018 8:36 am
by Lech Kulikowski
Hello,

Unfortunately, we do not have plans to add it at the current moment. Sorry.

Thank you.