开发者

convert string to smtpclient in c#

开发者 https://www.devze.com 2023-02-28 05:23 出处:网络
I am currently developing an asp.net web app. I have a 开发者_如何学运维class which is going to be used for sending an email.

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消