Last post Feb 14, 2012 02:55 PM by bbcompent1
Feb 14, 2012 01:43 PM|shabbir_215|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 = "email@example.com"
mail.To = "firstname.lastname@example.org"
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=188.8.131.52, Culture=neutral, PublicKeyToken=b77a5c561934e089]]: The "SendUsing" configuration value is invalid.
Thanks in Advance
Feb 14, 2012 02:10 PM|bbcompent1|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|shabbir_215|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|bbcompent1|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|shabbir_215|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|bbcompent1|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|shabbir_215|LINK
<network host="localhost" />
Feb 14, 2012 02:55 PM|bbcompent1|LINK
Ok, comment out the SmtpMail.SmtpServer. You are overriding what is in your web config.