ricky0309 Posted March 16, 2009 Share Posted March 16, 2009 Hi folks,First of all, I am a total newbie in web programming and my knowledge on ASP is limited to what taught in w3schools....=).I am currently trying to use ASP to help me send user input to my email.However, I am getting the following error message when I execute the ASP code below:Error message:CDO.Message.1 error '80040220'The "SendUsing" configuration value is invalid./yoursite/logic.asp, line 7 ASP code:<%Set myMail=CreateObject("CDO.Message")myMail.Subject="Sending email with CDO"myMail.From="mymail@mydomain.com"myMail.To="someone@somedomain.com"myMail.TextBody="This is a message."myMail.Sendset myMail=nothing%>It seems that the error message happens when executing myMail.Send command.Please kindly advise on how to get around this problem. FYI, I am using Windows Vista and IIS7 for my local server. Link to comment Share on other sites More sharing options...
justsomeguy Posted March 16, 2009 Share Posted March 16, 2009 I use this function to send mail. This is written in Javascript, so you would have to rewrite it if your code is VB, but it should give you an idea: function send_email_func (to, from, subject, body, replyto){ mailobj = Server.CreateObject("CDO.Message"); mailobj.From = from; mailobj.To = to; mailobj.Subject = subject; mailobj.TextBody = body; mailobj.ReplyTo = replyto; mailobj.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1; mailobj.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"; mailobj.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25; mailobj.Configuration.Fields.Update(); mailobj.Send(); delete mailobj;} There are references online that list the different configuration fields for CDO.Message and what they're used for (such as the sendusing field). Link to comment Share on other sites More sharing options...
ricky0309 Posted March 18, 2009 Author Share Posted March 18, 2009 Hi!! Thanks very much for the advice.Unfortunately I am still encountering an error even when I use the method you suggested. My code is as below:<html> <head> <script type="text/javascript"> function send_email_func () { mailobj = Server.CreateObject("CDO.Message"); mailobj.From = "abc@hotmail.com"; mailobj.To = "def@gmail.com"; mailobj.Subject = "Test"; mailobj.TextBody = "Hi!!"; mailobj.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1; mailobj.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"; mailobj.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25; mailobj.Configuration.Fields.Update(); mailobj.Send(); delete mailobj; } </script> </head> <body> <form> <input type="button", value="Send", onclick="send_email_func()"/> </form> </body></html>From the debugger tool, I was told that the error is "Server is not defined" and happens on line 6: mailobj = Server.CreateObject("CDO.Message");Any idea on what could be the problem here? Thanks!! =) Link to comment Share on other sites More sharing options...
justsomeguy Posted March 18, 2009 Share Posted March 18, 2009 You're trying to run this as regular Javascript, this is still ASP code and needs to go inside ASP tags. You can just use Javascript to write ASP instead of VB. <%@LANGUAGE="Javascript"%><%send_email_func('to@test.com', 'from@test.com', 'subject', 'the email text', 'replyto@test.com');function send_email_func (to, from, subject, body, replyto){ mailobj = Server.CreateObject("CDO.Message"); mailobj.From = from; mailobj.To = to; mailobj.Subject = subject; mailobj.TextBody = body; mailobj.ReplyTo = replyto; mailobj.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1; mailobj.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"; mailobj.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25; mailobj.Configuration.Fields.Update(); mailobj.Send(); delete mailobj;}%> Each ASP page can only use a single language, so if your pages are using VB instead of Javascript you'll need to convert one of them. Link to comment Share on other sites More sharing options...
ricky0309 Posted March 18, 2009 Author Share Posted March 18, 2009 Oops....got it, thanks for highlighting my mistake.I saved the code your given as .asp file and run it, but it still give me the original error below:CDO.Message.1 error '80040222'The pickup directory path is required and was not specified./yoursite/testing.asp, line 18 Any idea what causing this error? Link to comment Share on other sites More sharing options...
justsomeguy Posted March 18, 2009 Share Posted March 18, 2009 It sounds like the mail server isn't set up correctly. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.