Just nu i M3-nätverket
Jump to content

skicka mail med C# på win2003


Mr Jones

Recommended Posts

Jag färsöker skicka ett mail via en aspx sida med följande kod:

MailMessage Message = new MailMessage();
		Message.To = "namn@domain.se";
		Message.From = "namn.efernamn@domain.se";
		Message.Subject = "subject";
		//Message.Body = args[3];

		try
		{
			SmtpMail.SmtpServer = "Web01.domain.se";
			SmtpMail.Send(Message);
		}
		catch(System.Web.HttpException ehttp)
		{
			Response.Write(ehttp.Message+"<HR>");
			Response.Write("Here is the full error message output"+"<HR>");
			Response.Write(ehttp.ToString());
		}

 

Följande fel får jag upp:

[log]

System.Web.HttpException: Could not access 'CDO.Message' object. ---> 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 namn@domain.se --- 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 invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) --- End of inner exception stack trace --- at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) at System.Web.Mail.CdoSysHelper.Send(MailMessage message) at System.Web.Mail.SmtpMail.Send(MailMessage message) at sorg.Mail.Page_Load(Object sender, EventArgs e)

[/log]

 

Link to comment
Share on other sites

Rätt uppenbart (?) om du kollar i felmeddelandet:

The server rejected one or more recipient addresses. The server response was: 550 5.7.1 Unable to relay for namn@domain.se

 

Kolla Suggestion 4 och Suggestion 5 i Anjunas länk.

 

/Cluster

------------------------------------------------------

"Den som försummar att dricka ur erfarenhetens källa

kommer troligen att dö av törst i okunnighetens öken."

------> http://eforum.kicks-ass.net <------

 

Link to comment
Share on other sites

Löste det genom att använda följande smtpserver:

 

SmtpMail.SmtpServer.Insert( 0, "127.0.0.1");

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.



×
×
  • Create New...