Solved

Error while sending mail

Posted on 2002-07-08
4
242 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
  • 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

758 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now