Free Support Forum -

How to read SMTP settings from Web.config (C#)

I’m in the process of replacing references to with aspose email and run into issues while sending an email. The error seems to be with initiating the smtp client, which in .net email library uses the web.config settings but has to be explicitly specified for aspose email smtp client. Is there an easy way to read settings from the config file? I found a similar thread from 2006 with this question but it did not have the solution I was looking for.


I have observed your requirements and like to share that it depends on your programing approach that how and where you store the setting parameters for initializing SMTP client on your end. Infact, this things is not related to Aspose.Email API. You need to provide the valid credential for connecting SMTP account and it should work.

Thanks for your response. Reading the smtp server settings should be part of the documentation, since we cannot be expected to use hardcoded credentials or server IPs. In the past thread I referred to, it was mentioned that this was being looked into. Utilizing mailSettings config section?

As for the last part of your response, I did provide valid credentials but I’m guessing I probably missed setting a specific property. An example of reading these properties from a config file would be helpful. Thanks!


We looking into this on our end either is it possible or not and will get back to you with feedback soon.

1 Like

Here’s additional information on the error I receive:

AsposeException: Failure sending mail. —> SmtpException: Failure sending mail. —>
System.ArgumentNullException: Value cannot be null.

I have the stack trace but most of the information in it is encrypted, I could send a PM with the information if needed.

For your reference these are the properties am setting when I get the error:

Dim client As New sysMail.Clients.Smtp.SmtpClient()

        client.Timeout = 600000

        client.Host = ""
        client.UseDefaultCredentials = True
        client.DeliveryMethod = sysMail.Clients.Smtp.SmtpDeliveryMethod.Network
        client.Port = 25


Can you also please confirm that I can use our total license to initialize? Do I need an email license separately?



I like to inform that you can use Total license with all products of Aspose.

Thank you! Were you able to look at the earlier issue I was having with initiating the smtp client object?


I suggest you to please visit this documentation link for more about connecting SMTP server.