Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 14, 2012 02:55 PM by bbcompent1
Feb 14, 2012 01:43 PM|LINK
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("Below given events are failed to process in the portal. ")
mail.From = "firstname.lastname@example.org"
mail.To = "email@example.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
Previously On iis6.0 it was working fine but on IIS 7.5 it display below error, Could anyone help me
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=18.104.22.168, Culture=neutral, PublicKeyToken=b77a5c561934e089]]: The "SendUsing" configuration value is invalid.
Thanks in Advance
Feb 14, 2012 02:10 PM|LINK
'Specify to use the default Smtp Server SmtpMail.SmtpServer = ""
Could the fact you didn't specify your email server be the issue??? Unless you left this intentionally blank.
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.
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.
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
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???
Feb 14, 2012 02:52 PM|LINK
<network host="localhost" />
Feb 14, 2012 02:55 PM|LINK
Ok, comment out the SmtpMail.SmtpServer. You are overriding what is in your web config.