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
Solved

Emailing through asp.net

Posted on 2004-09-27
4
221 Views
Last Modified: 2012-05-05
I've written a program that sends a confirmation email after the user submits.  The code points to the email server we have and the emails were sending fine when I was testing the program on my localhost.  Now I have moved the application to the web server and it will not send an email.  I've tried sending it to several addresses to make sure, but it fails to email every time.  Here is my code:
        Dim eMail As New MailMessage
        eMail.Body = strMessage
        eMail.From = "noreply@adtrav.com"
        eMail.Subject = "Approval Needed"
        eMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1")
        eMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "matt@adtrav.com")
        eMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "somepassword")
        eMail.BodyFormat = MailFormat.Html
        SmtpMail.SmtpServer = "mail.adtrav.com"
        eMail.To = "matt.jacoby@adtrav.com"      
        SmtpMail.Send(eMail)
       
        I am not familiar with the fields.add part, but I have been told that this can be given the email address and password of a valid account and it should work.  I have also tried it without those three lines and it still doesn't work.  Help!  I am giving away all the points I have left and this is very urgent!
       
0
Comment
Question by:jacobymatt
  • 2
4 Comments
 
LVL 1

Expert Comment

by:muellerfan
ID: 12164968
Are you getting an error message?  Are you sure the production server has access to the SMTP server?
0
 
LVL 6

Accepted Solution

by:
viola123 earned 40 total points
ID: 12166366
i am not sure what is happening because you didn't provide any error message.

but i suggest you checking your IIS configuration.

1. check your file system, make sure it's ntfs system

2. check c:\winnt\system32\cdosys.dll, make sure you checked all access in security tab of property window

3. in IIS, open the property window of your virtual smtp server and grant access to any other machine, which is supposed to be able to send/receive email from that machine.

cheers
viola
0
 

Author Comment

by:jacobymatt
ID: 12169299
Thanks for the help guys.  This is the error I was able to see when I ran the application from the web server.  I just got in this morning so I will check those settings but I just wanted to go ahead and post this in case it was obvious what the problem was.  

[COMException (0x80040213): The transport failed to connect to the server.
]

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) +0
   System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) +473
   System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) +58

[HttpException (0x80004005): Could not access 'CDO.Message' object.]
   System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) +113
   System.Web.Mail.CdoSysHelper.Send(MailMessage message) +1861
   System.Web.Mail.SmtpMail.Send(MailMessage message) +150
   ERC_RezApprove.form.sendEmail(String strMessage, String strApprovee, String strTA, String strApprover) in c:\inetpub\wwwroot\ERC_RezApprove\AuthForm.aspx.vb:695
   ERC_RezApprove.form.btnRequestApp_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\ERC_RezApprove\AuthForm.aspx.vb:739
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
   System.Web.UI.Page.ProcessRequestMain() +1292

0
 

Author Comment

by:jacobymatt
ID: 12170553
Well, thanks anyway but I figured out that I needed to inlcude my mail server in my host file because it was trying to locate it by its external ip address instead of going through our network to reach it.  But I don't really understand why it would not be able to find it by the external ip address.  If anyone has a clue it would be nice to know why the external path would be a problem.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Checkbox in a dynamic GridVIew is not clickable? 5 37
How to create an MVC5, Razor Widget 2 26
Error handling in asp.net site 5 34
No Data for DropDown List 2 28
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

860 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