c# - smtp mailSettings from -
is possible use "from" in config file mailmessage.from when creating email in .net. having trouble accessing it. whenever try referring configurationmanager not exist error referencing them, see below.
<mailsettings> <smtp from="test@test.org" deliverymethod="network"> <network host="smtpsend" defaultcredentials="true"/> </smtp> </mailsettings> using system.net.mail; using system.net; using system.configuration; using system.net.configuration; mailmessage msg = new mailmessage(); msg.from = ***~~** msg.subject = string.format(subject); msg.isbodyhtml = true; msg.body = body; msg.priority = mailpriority.normal; msg.to.add("me"); smtpclient client = new smtpclient(); client.send(msg);
good afternoon have added actual reference system.configuration dll library? can check looking in references folder of project in solution explorer. if not there, right click project , choose add references option. click on .net tab search system.configuration. should take care of reference issue. additionally, specifying address in config file believe not have reset again when making request send email.
Comments
Post a Comment