Solved

Error while sending mail

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# Error - Add Failed 12 78
How to get the web content with different encodings 2 27
Please explain "Multi-Tenant Services" 5 62
Entity Framework 7 31
Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

911 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

21 Experts available now in Live!

Get 1:1 Help Now