Tell me more ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

        }
    }
}
share|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

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

Questions on Super User are expected to relate to computer software or computer hardware within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

Browse other questions tagged or ask your own question.