Link to home
Start Free TrialLog in
Avatar of mathieu_cupryk
mathieu_cuprykFlag for Canada

asked on

Using Import Name Spaces

I am working on ImportNameSpaces, here is the code...

<%@Import NameSpace="System.Web.Mail"%>

<Script runat="server">

Sub Page_Load
  Dim mailMessage As SmtpMail
 
  mailMessage.Send( _
    "bob@somewhere.com",_
    "alice@somewhere.com",_
    "Sending Mail!",_
    "Hello!")
End Sub
</Script>

<html>
  <head>
    <title>ImportNameSpace</title>
  </head>
  <body>
  <h2>Email Sent!</h2>
  </body>
</html>


I am getting an error only when I try to dispaly in the browser but not in design mode in Visual Studio.
************************************************************************************
Here is one error I get when I take out the underscore....(
"bob@somewhere.com",_
"alice@somewhere.com",_
"Sending Mail!","Hello!"_ )

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

Source Error:


Line 6:    Dim mailMessage As SmtpMail
Line 7:    
Line 8:    mailMessage.Send("bob@somewhere.com","alice@somewhere.com","Sending Mail!","Hello!" )
Line 9:  End Sub
Line 10: </Script>
 

Source File: c:\inetpub\wwwroot\simple001\ImportNameSpace.aspx    Line: 8
*************************************************************************************
Now if I put  the underscore back in  I get this error...
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30201: Expression expected.

Source Error:

 

Line 6:    Dim mailMessage As SmtpMail
Line 7:    
Line 8:    mailMessage.Send(
Line 9:    "bob@somewhere.com",_
Line 10:   "alice@somewhere.com",_
 

Source File: c:\inetpub\wwwroot\simple001\ImportNameSpace.aspx    Line: 8


Can you explain what it is I am doing wrong. I have had someone else look at it  and they dont see the error either.

Any help would be wonderful.
Thanks in Advance.
M
Avatar of razo
razo

u should have a space between the comma and the _
ASKER CERTIFIED SOLUTION
Avatar of raterus
raterus
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mathieu_cupryk

ASKER

Well I did as You said, It is still giving me an error.So that wasnt the problem.
Thanks for trying. There is something else in there.
m
Can you reference a mail server to do the page?

I changed the code a bit.

Now if I look at it in design mode it tells me the email is sent. So the reason I can not view it in the browser is because I dont have the SmtpMail.SmtpServer?

There is a way to configure the server with a default mail server if you don't set it, I'm not sure how it is done though.