Issues with your account? Bug us in the Discord!

[ASP.NET/JScript] How to send an email?

RubberEagleRubberEagle What's a rubber eagle used for, anyway?
Hi
I'm working on an ASP page that is supposed to send an email with attachement.
Now I have absolutely no real experience with ASP.Net and JScript, I have only used PHP and JSP (though that quite extensively).
I've found the MS .net classes (System.Web.Mail namespace), and basically have written the code to send the mail.
my problem now is that the page doesn't find the mailing classes.
I've tried using the import statement, but i only get errormessages for that.
when i do

([ stands for <, because with < the server thinks this is server-scripting and doesn't show the text)
[code]
[%@ LANGUAGE = "JScript"%]
[%@ import namespace="System.Web.Mail"%]
[/code]

I get "the <%@ statement can only be used once per asp page" (or something similar), which afaik is total bull-exceremets...
Adding it with a , or ; or whatever behind the language statement also doesn't work.
when i write
[code]
[%@ LANGUAGE = "JScript"%]
[%
import System.Web.Mail;

...
%]
[/code]
or
[code]
[%@ LANGUAGE = "JScript"%]
import System.Web.Mail;
[%
...
%]
[/code]

I get error messages..

my code for sending the mail looks like this:
[code]
var mail = new MailMessage;
mail.From="c.gritsch@mobilkom.at";
mail.To="c.gritsch@mobilkom.at";
var attachment = new MailAttachment;
attachment.Filename=Server.MapPath("XMLtest/mailDocument.xml");
mail.Attachments.Add(attachment);

var smtp = new SmtpMail;
smtp.SmtpServer="smtp.mobilkom.at";
smtp.send(mail);
[/code]
Without the importstatement i get
"Error Type:
Microsoft JScript runtime (0x800A1391)
'MailMessage' is undefined"

The biggest problem i have is that i don't even really know how to define a new variable, and that they have tutorials for EVERY FRACKING LANGUAGE BUT JSCRIPT on the msdn pages...

so, if anybody could help, it'd be great...
Sign In or Register to comment.