SMTP setting in web.configs

Stimulsoft Reports.WEB discussion
Post Reply
JohnW
Posts: 103
Joined: Mon Nov 20, 2017 8:29 pm

SMTP setting in web.configs

Post 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
Lech Kulikowski
Posts: 6245
Joined: Tue Mar 20, 2018 5:34 am

Re: SMTP setting in web.configs

Post by Lech Kulikowski »

Hello,

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

Thank you.
JohnW
Posts: 103
Joined: Mon Nov 20, 2017 8:29 pm

Re: SMTP setting in web.configs

Post 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.
JohnW
Posts: 103
Joined: Mon Nov 20, 2017 8:29 pm

Re: SMTP setting in web.configs

Post 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>
  
  
Lech Kulikowski
Posts: 6245
Joined: Tue Mar 20, 2018 5:34 am

Re: SMTP setting in web.configs

Post 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.
JohnW
Posts: 103
Joined: Mon Nov 20, 2017 8:29 pm

Re: SMTP setting in web.configs

Post 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
JohnW
Posts: 103
Joined: Mon Nov 20, 2017 8:29 pm

Re: SMTP setting in web.configs

Post 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]
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: SMTP setting in web.configs

Post 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
JohnW
Posts: 103
Joined: Mon Nov 20, 2017 8:29 pm

Re: SMTP setting in web.configs

Post by JohnW »

Using the code I provided works. I would think a there must be a cleaner way to implement it.
Lech Kulikowski
Posts: 6245
Joined: Tue Mar 20, 2018 5:34 am

Re: SMTP setting in web.configs

Post by Lech Kulikowski »

Hello,

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

Thank you.
Post Reply