Jump to content

Sending email from asp


boylesg

Recommended Posts

Have tried this:myMail=Server.CreateObject("CDO.Message");myMail.Subject="Sending email with CDO";myMail.From="mymail@mydomain.com";myMail.To="greg@gregsindigenouslandscapes.com.au";myMail.TextBody="This is a message.";//myMail.Send();It is all good until you get to the last line, which causes an internal server error.Any hints on how to do this successfully?

Link to comment
Share on other sites

going by http://www.w3schools.com/asp/asp_send_email.asp, it should be set up like this<%Set myMail=CreateObject("CDO.Message")myMail.Subject="Sending email with CDO"myMail.From="mymail@mydomain.com"myMail.To="greg@gregsindigenouslandscapes.com.au";myMail.TextBody="This is a message."myMail.Sendset myMail=nothing%>
Surely the script language you use is irrelevant?I actually pasted this javascript example above from else where and changed some of the values.
Link to comment
Share on other sites

its not javascript, its vbscript, server scripting use different methods to carry out certain actions, by not setting the mymail as in 'Set myMail' might i thought be the problem, as i have not used vbscript for ages, or set up to use VB now, i could not fully this this out.

Link to comment
Share on other sites

its not javascript, its vbscript, server scripting use different methods to carry out certain actions, by not setting the mymail as in 'Set myMail' might i thought be the problem, as i have not used vbscript for ages, or set up to use VB now, i could not fully this this out.
Well apparently the server is OK with myMail=Server.CreateObject("CDO.Message");otherwise I would get a server error due to my accessing of fields in a non-existent object.Found this in the log of the server: The__SendUsing__configuration_value_is_invalid._Doesn't mean all that much to me because I have not found a list of methods and properties in CDO.Message object.
Link to comment
Share on other sites

ok! then did you access iis, right click smtp and set the configuration setting to send mail by any chance.
After a bit of searching on that cryptic error message I have since added this:myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")=2;myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")="127.0.0.1";myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=8025;myMail.Configuration.Fields.Update();This seems to pass the server but the .Send() still causes n internal server error.Perhaps they are not the right settings?
Link to comment
Share on other sites

After a bit of searching on that cryptic error message I have since added this:myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")=2;myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")="127.0.0.1";myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=8025;myMail.Configuration.Fields.Update();This seems to pass the server but the .Send() still causes n internal server error.Perhaps they are not the right settings?
Error in server log file: Wrong_number_of_arguments_or_invalid_property_assignment
Link to comment
Share on other sites

I typically use this function to send my mail through ASP:

function send_email_func (to, from, subject, body){  mailobj = Server.CreateObject("CDO.Message");  mailobj.From = from;  mailobj.To = to;  mailobj.Subject = subject;  mailobj.TextBody = body;  mailobj.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1;  mailobj.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mailbox.domain.com";  mailobj.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25;  mailobj.Configuration.Fields.Update();  mailobj.Send();  delete mailobj;}

You may need to modify some of the configuration values. I don't remember what the different values for sendusing mean, but you may want to look those up and make sure you're using the right one.

Link to comment
Share on other sites

Surely the script language you use is irrelevant?
How could the script language possibly be irrelevant?? If you're using ASP, you have to write the code in ASP. If you're using PHP, you have to write the code in PHP, and so on.
Link to comment
Share on other sites

ASP isn't a language though, it's a framework. You can write ASP code with several different languages, including Javascript (Jscript) and VBScript. Some of the code in this thread is written in VBScript, and some is written in Jscript, but it's all ASP.

Link to comment
Share on other sites

I typically use this function to send my mail through ASP:
function send_email_func (to, from, subject, body){  mailobj = Server.CreateObject("CDO.Message");  mailobj.From = from;  mailobj.To = to;  mailobj.Subject = subject;  mailobj.TextBody = body;  mailobj.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1;  mailobj.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mailbox.domain.com";  mailobj.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25;  mailobj.Configuration.Fields.Update();  mailobj.Send();  delete mailobj;}

Its cool now. I got in contact with the system administrator and he told me the correct configuration settings......and it worked at long last.You may need to modify some of the configuration values. I don't remember what the different values for sendusing mean, but you may want to look those up and make sure you're using the right one.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...