I have got the following Exception :
System.Reflection.TargetInvocationException:
Exception has been thrown by the target of an invocation. -
System.Runtime.InteropServices.COMException (0x8004020F):
The server rejected one or more recipient addresses. The server response was: 550 5.7.1 Unable to relay for
[email protected]
--- End of inner exception stack trace ---
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) at System.Type.InvokeMember(String name, BindingFlags, invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture)
at System.Web.Mail.SmtpMail.LateBoundAccessHelper.CallMethod(Type type, Object obj,
String methodName, Object[] args) at
System.Web.Mail.SmtpMail.LateBoundAccessHelper.CallMethod(Object obj,
String methodName, Object[] args)
public static void SendEmail(string _FromEmail,
string _ToEmail,
string _Subject,
string _EmailBody)
{
// setup email header .
SmtpMail.SmtpServer = "127.0.0.1";
MailMessage _MailMessage = new MailMessage();
_MailMessage.From = _FromEmail;
_MailMessage.To = _ToEmail;
_MailMessage.Subject = _Subject;
_MailMessage.Body = _EmailBody;
try
{
SmtpMail.Send(_MailMessage);
}
catch (Exception ex)
{
if (ex.InnerException != null)
{
String str = ex.InnerException.ToString();
}
}
}