Solved

Error while sending mail

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

777 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