nirmalas
asked on
Error while sending mail
Hi,
I have a ASPX which sends mails to users.
The code is :
try
{
MailMessage mailMsg = new MailMessage();
mailMsg.To = strToAddress;
mailMsg.From = strFromAddress;
mailMsg.Subject = strSubject;
mailMsg.BodyFormat = MailFormat.Text;
mailMsg.Body=strMessageBod y;
SmtpMail.Send(mailMsg);
return "Message was successfully sent.";
}
catch(Exception ex)
{
return ex.InnerException + ex.StackTrace + ex.Message;
}
The stack trace is given below:
System.Reflection.TargetIn vocationEx ception: Exception has been thrown by the target of an invocation. ---> System.UnauthorizedAccessE xception: Access is denied. --- End of inner exception stack trace --- at System.RuntimeType.InvokeD ispMethod( String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) at System.RuntimeType.InvokeM ember(Stri ng name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) at System.Web.Mail.LateBoundA ccessHelpe r.CallMeth od(Object obj, String methodName, Object[] args) at System.Web.Mail.LateBoundA ccessHelpe r.CallMeth od(Object obj, String methodName, Object[] args) at System.Web.Mail.CdoSysHelp er.Send(Ma ilMessage message) at System.Web.Mail.SmtpMail.S end(MailMe ssage message) at WWSFE.Util.SendEmail(Strin g strToAddress, String strFromAddress, String strSubject, String strMessageBody) in c:\inetpub\wwwroot\wws\cla ssfile\wws fe.cs:line 2274Could not access 'CDO.Message' object.
How to overcome this problem.
Thanks in advance,
Nirmala S.
I have a ASPX which sends mails to users.
The code is :
try
{
MailMessage mailMsg = new MailMessage();
mailMsg.To = strToAddress;
mailMsg.From = strFromAddress;
mailMsg.Subject = strSubject;
mailMsg.BodyFormat = MailFormat.Text;
mailMsg.Body=strMessageBod
SmtpMail.Send(mailMsg);
return "Message was successfully sent.";
}
catch(Exception ex)
{
return ex.InnerException + ex.StackTrace + ex.Message;
}
The stack trace is given below:
System.Reflection.TargetIn
How to overcome this problem.
Thanks in advance,
Nirmala S.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
its for security reasons, you have to specify this , i assume SMTP is configured setting localhost to 121.0.0.1 blah blah
I think you should configure the SmtpServer to a specific Ip.
I believe that will solve the problem.
I believe that will solve the problem.
Force Accepted
SpideyMod
Community Support Moderator @Experts Exchange
SpideyMod
Community Support Moderator @Experts Exchange