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 ragaei.mahmoud@invensys.com  


--- 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();

        }
    }
}
link|improve this question
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 ragaei.mahmoud@invensys.com – ragaei Jun 22 '11 at 6:20
--- 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 – ragaei Jun 22 '11 at 6:20
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) – ragaei Jun 22 '11 at 6:20
feedback

closed as off topic by Sathya Jun 22 '11 at 7:16

Questions on Super User are expected to generally relate to computer software or computer hardware, within the scope defined in the faq.

Browse other questions tagged or ask your own question.