Solved

Error while sending mail

Posted on 2002-07-08
4
254 Views
Last Modified: 2010-04-15
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=strMessageBody;    
     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.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.UnauthorizedAccessException: Access is denied. --- 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) 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 WWSFE.Util.SendEmail(String strToAddress, String strFromAddress, String strSubject, String strMessageBody) in c:\inetpub\wwwroot\wws\classfile\wwsfe.cs:line 2274Could not access 'CDO.Message' object.
 
How to overcome this problem.

Thanks in advance,
Nirmala S.

0
Comment
Question by:nirmalas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
Yog earned 100 total points
ID: 7138407
try setting
SmptMail.SmtpServer = "localhost";
or the IP address
0
 
LVL 5

Expert Comment

by:Yog
ID: 7138570
its for security reasons, you have to specify this , i assume SMTP is configured setting localhost to 121.0.0.1 blah blah
0
 
LVL 1

Expert Comment

by:GuryTraub
ID: 7152471
I think you should configure the SmtpServer to a specific Ip.
I believe that will solve the problem.
0
 

Expert Comment

by:SpideyMod
ID: 8279407
Force Accepted

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

742 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question