I am using .NET 4.0 and IIS 7.5 to send an email using below code
Private Sub SendMail()
Dim strQuery As New StringBuilder
Dim mail As New MailMessage()
strQuery.AppendLine("Dear sir,")
strQuery.AppendLine("Below given events are failed to process in the portal. ")
mail.From = "webmaster@xxx.com"
mail.To = "shabbir@xxx.com"
mail.Subject = "Test"
mail.Body = Convert.ToString(strQuery.ToString())
mail.BodyFormat = MailFormat.Text
'Specify to use the default Smtp Server
SmtpMail.SmtpServer = ""
'Now, to send the message, use the Send method of the SmtpMail class
SmtpMail.Send(mail)
End Sub
Previously On iis6.0 it was working fine but on IIS 7.5 it display below error, Could anyone help me
The "SendUsing" configuration value is invalid.
Description:
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ServiceModel.FaultException`1[[System.ServiceModel.ExceptionDetail, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]: The "SendUsing" configuration value is invalid.
Actually in your code you do need to somewhere, even if you define it in your web config, the smtpserver has to be specified unless you are using some email helper class that you've coded.
shabbir_215
Member
427 Points
419 Posts
The "SendUsing" configuration value is invalid.
Feb 14, 2012 01:43 PM|LINK
Hi Everyone,
I am using .NET 4.0 and IIS 7.5 to send an email using below code
Private Sub SendMail() Dim strQuery As New StringBuilder Dim mail As New MailMessage() strQuery.AppendLine("Dear sir,") strQuery.AppendLine("Below given events are failed to process in the portal. ") mail.From = "webmaster@xxx.com" mail.To = "shabbir@xxx.com" mail.Subject = "Test" mail.Body = Convert.ToString(strQuery.ToString()) mail.BodyFormat = MailFormat.Text 'Specify to use the default Smtp Server SmtpMail.SmtpServer = "" 'Now, to send the message, use the Send method of the SmtpMail class SmtpMail.Send(mail) End SubPreviously On iis6.0 it was working fine but on IIS 7.5 it display below error, Could anyone help me
The "SendUsing" configuration value is invalid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ServiceModel.FaultException`1[[System.ServiceModel.ExceptionDetail, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]: The "SendUsing" configuration value is invalid.
Source Error:
Thanks in Advance
Shabbir
bbcompent1
All-Star
33063 Points
8516 Posts
Moderator
Re: The "SendUsing" configuration value is invalid.
Feb 14, 2012 02:10 PM|LINK
Could the fact you didn't specify your email server be the issue??? Unless you left this intentionally blank.
shabbir_215
Member
427 Points
419 Posts
Re: The "SendUsing" configuration value is invalid.
Feb 14, 2012 02:30 PM|LINK
I have left it blank only because it was working fine previoulsy, I don't have to define SMTP server.
bbcompent1
All-Star
33063 Points
8516 Posts
Moderator
Re: The "SendUsing" configuration value is invalid.
Feb 14, 2012 02:41 PM|LINK
Actually in your code you do need to somewhere, even if you define it in your web config, the smtpserver has to be specified unless you are using some email helper class that you've coded.
shabbir_215
Member
427 Points
419 Posts
Re: The "SendUsing" configuration value is invalid.
Feb 14, 2012 02:45 PM|LINK
But as i said it was not required to Specify when using IIS6.0 so please let me know where should i specify smtp server
bbcompent1
All-Star
33063 Points
8516 Posts
Moderator
Re: The "SendUsing" configuration value is invalid.
Feb 14, 2012 02:47 PM|LINK
IIS 6 is usually much more forgiving about this since you probably had the smtp server on the local server. Can you post your web config file???
shabbir_215
Member
427 Points
419 Posts
Re: The "SendUsing" configuration value is invalid.
Feb 14, 2012 02:52 PM|LINK
<system.net> <mailSettings> <smtp from="webmaster@xxx.com"> <network host="localhost" /> </smtp> </mailSettings> </system.net>bbcompent1
All-Star
33063 Points
8516 Posts
Moderator
Re: The "SendUsing" configuration value is invalid.
Feb 14, 2012 02:55 PM|LINK
Ok, comment out the SmtpMail.SmtpServer. You are overriding what is in your web config.