Friday, March 16, 2012

NEWBIE NEEDS HELP! Listings dont run...

Hi,

I'm a newbie trying to get ahead of this learning curve but I'm having a lot of trouble getting listings and samples to run on my machine (Win XP, new box, IIS 5.1 installed, SMTP service started...). I'm using two books primarily, ASP .NET Unleashed 2nd ed. and Intro to ASP .Net by Kathleen Kalata (Thompson). I'm using VS .NET 1.1 and I'm having trouble with the samples and listings from both books. I think it may be an issue with IIS but I am so new to this I don't know where to begin and honestly I'd much rather be learning ASP than troubleshooting VS or IIS or whatever. Maybe that's naive but I'm pretty much in the dark either way. I'm hoping someone here will be able to help. I really want to learn this and its getting pretty frustrating. How am I supposed to find my mistakes if I can't even get the code provided with the books to work? Any way, here is is the code from ASP Unleased that is failing followed by the debug report. If this works out then maybe we can also look at the code from Kalata's book. I would be very grateful for a hand getting started with this.

//CODE SAMPLE Listing 1.12 pg. 45 of ASP .NET Unleashed

<%@dotnet.itags.org. Page Language="VB" Debug="true" %
<%@dotnet.itags.org. Import Namespace="System.Web.Mail" %
<Script Runat="Server"
Sub Page_Load
Dim mailMessage As SmtpMail

mailMessage.Send( _
"bob@dotnet.itags.org.somewhere.com", _
"alice@dotnet.itags.org.somewhere.com", _
"Sending Mail!", _
"Hello!" )
End Sub

</Script
<html>
<head><title>ImportNamespace.aspx</title></head>
<body
<h2>Email Sent!</h2
</body>
</html>
//END CODE SAMPLE

//ERROR REPORT
Server Error in '/' Application.
------------------------

The "SendUsing" configuration value is invalid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: The "SendUsing" configuration value is invalid.

Source Error:

Line 8: Dim mailMessage As SmtpMail
Line 9:
Line 10: mailMessage.Send( _
Line 11: "bob@dotnet.itags.org.somewhere.com", _
Line 12: "alice@dotnet.itags.org.somewhere.com", _

Source File: c:\inetpub\wwwroot\asp-unleashed\MyFiles\chap01\ImportNamespace.aspx Line: 10

Stack Trace:

[COMException (0x80040220): The "SendUsing" configuration value is invalid.
]

[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) +1840
System.Web.Mail.CdoSysHelper.Send(String from, String to, String subject, String messageText) +74
System.Web.Mail.SmtpMail.Send(String from, String to, String subject, String messageText) +171
ASP.ImportNamespace_aspx.Page_Load() in c:\inetpub\wwwroot\asp-unleashed\MyFiles\chap01\ImportNamespace.aspx:10
System.Web.Util.ArglessEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +10
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731

------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
//END ERROR REPORTIt apparently can't find an SMTP server, with which to send the email

First - is it WinXP Home or WinXp Pro - -
You'd need WinXP pro to have IIS and an smtp running on your computer - - and:
Secondly - do you have an SMTP server running on your computer?
Thanks David,

(XP Pro) Well, that's what I though also. So I checked control panel/ services and found that SMTP is running. I'm running IIS locally as a student and I doubt somehow that I could actually send email from this server to a mail recipient on the web through my Verizon DSL account but that shouldn't stop the page from running, right? Maybe this is some configuration issue?
There are all kinds of issues with sending e-mails and .net

we are fighting with the CDO stuff right now as well - the issue
is with CDONTS

there are MANY FAQ's and tech white papers on how to fix this problem -
but so far NONE have corrected it...

here is a link to a joint that is having the exact same problem...

http://www.ultraapps.com/disc_thread.asp?mid=2712&app_id=1&

and this link...

http://www.genesis-hosting.com/?pagename=cdontshowto

we did all the suggested stuff, and it still doesn't work ...

good luck
No. Seriously? Using forms to send email is like the most basic thing going. How could something as sophisticated and successful as ASP .Net fail on something so basic. I find this very hard to beleive and that newsgroup you sent me too isn't quit right either, is that some kind of demo for the applications for sale on the site or are you for real?

I just want someone to look at the code and error report and tell me what they tink is going on. 57 people have read this and only 3 have responded. Does this mean that none of you know what is going on or what?
Try modifying the following code snippet:

Dim lMailMsg As New Mail.MailMessage
lMailMsg.To = "bob@.somewhere.com,alice@.somewhere.com"
lMailMsg.From = "ubwa@.somewhere.com"
lMailMsg.Subject = ""Sending Mail!""
lMailMsg.Priority = Mail.MailPriority.High
lMailMsg.BodyFormat = Mail.MailFormat.Text
lMailMsg.BodyFormat = rbutBodyFormat.SelectedItem.Value
lMailMsg.Body = "Hello!"

' Commented out example of how to handle attachments
'Dim lAttachment As New Mail.MailAttachment("c:\temp\TestAttachment.txt", Mail.MailEncoding.Base64)
'lMailMsg.Attachments.Add(lAttachment)

Dim lSMTPMail As Mail.SmtpMail
lSMTPMail.SmtpServer = ConfigurationSettings.AppSettings("SMTPServer") ' This should be the IP address of your Verizon SMTP server
lSMTPMail.Send(lMailMsg)

You are correct that sending email is a very basic concept. The issues that I have had all revolove around correctly configuring the SMTP server component on the backend.
I ran the script you posted ubwa and everything worked fine. I could not reproduce your error.
I would also recommend that you use try/catch error handling in your code to determine what is really going on as well. You should also be aware that the outermost exception message is usually not meaningful when working with SMTP mail. Refer to the following code snippet:

dim lLogText as string

try

...your email code

catch ex as exception

If IsNothing(ex.InnerException) = True Then
lLogText = "Failure encountered while attempting to email a report:" & vbCrLf & vbCrLf & ex.Message & vbCrLf & vbCrLf & ex.StackTrace
ElseIf IsNothing(ex.InnerException.InnerException) = True Then
lLogText = "Failure encountered while attempting to email a report:" & vbCrLf & vbCrLf & ex.InnerException.Message & vbCrLf & vbCrLf & ex.StackTrace
Else
lLogText = "Failure encountered while attempting to email a report:" & vbCrLf & vbCrLf & ex.InnerException.Message & "::" & ex.InnerException.InnerException.Message & vbCrLf & vbCrLf & ex.StackTrace
End If

.... write to an external log file

end try
Yes - I am for real - and as you have seen from the
trouble you are having - there is a problem.

If you were to take a few moments and read the posts for both of those sites,
you would have seen that you are not alone in this problem.

As for you getting cocky and bashing us for trying to help you,

you posted the request for free help

FREE help -

we don't work for you - we are volunteering our time to try to assist you in your efforts.

If you don't like the answers or suggestions that are given - then don't post questions here.

Pretty simple concept.
Whoa, please, I meant no offense and it wasn't my intention to bash anyone. I very much appreciate this community and the time people take help others. If my tone is off its just because I'm frustrated that I'm spending more time troubleshooting than I am learning to use ASP .Net. I apologise.

0 comments:

Post a Comment