convert string to smtpclient in c#
I am currently developing an asp.net web app. I have a 开发者_如何学运维class which is going to be used for sending an email.
I want to get the SMTP Server address from a MySQL Database. To get the value from the MySQL Database I am using
string smtp = reader.GetString("smtp_server");
For assigning the smtp server to the mail function I am using
SmtpClient server = new SmtpClient(smtp);
Hoever, I am getting the error unable to convert from string to SmtpClient. I have tried to add a cast of (SmtpClient) but it is not letting me do this.
Thanks for any help you can provide.
Are you sure the error is happening where you think it's happening. The SmtpClient
class has a constructor which accepts a string. I get the feeling there's more happening in your code than you're sharing with us. Can you show us more code?
精彩评论