[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 637
  • Last Modified:

problem because of I am not split it with ";"

Textarea name=sendmail previously must be in type of xxxx@email.com;yyyy@??.com and so on...
Now I use function addmail to add email address to "sendmail" and when added it, it will show:
xxxx@email.com
yyyy@??.com
and so on at Textarea name=sendmail...

I received error msg:
006~ASP 0177~Server.CreateObject Failed~Invalid class string

I think the problem because of I am not split it with ";":
emailflag=4
 Jmail_msg()
 --------------
      rcpt=split(mailto,",")
      for i=0 to ubound(rcpt)
            msg.AddRecipient rcpt(i) 'Ôö¼ÓÊÕ¼þÈË
      next
      
Please edit functions so that sub Jmail_msg() is working
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<%
      if request("action")="send" then
            call sendemail()
      else
            call writelettle()
      end if

sub writelettle()%>
<SCRIPT language=Javascript>
            <!--
            function sendmail_submit(){
                  temp=document.sendmail.from.value;
                  if(document.sendmail.Subject.value.length==0)
                        {
                              alert("Ö÷Ìâ²»ÄÜΪ¿Õ£¡");
                              document.sendmail.Subject.focus();
                              return false;
                        }
                  if ((temp.indexOf("@")==-1) || (temp.indexOf("@")!=temp.lastIndexOf("@")) || temp.indexOf("@")==temp.length-1)
                        {
                              alert("Çë¼ì²é»Ø¸´µØÖ·£¡");
                              document.sendmail.from.focus();
                              return false;
                        }
                  var count;
                     count=document.sendmail.sendmail.length;
                     if (count==0)
                           {
                                 alert("ÓʼþµØÖ·²»ÄÜΪ¿Õ£¡");
                                 return false;
                           }
                  if(document.sendmail.Content.value.length==0)
                        {
                              alert("EmailÕýÎIJ»ÄÜΪ¿Õ£¡");
                              document.sendmail.Content.focus();
                              return false;
                        }
                  for (i=0;i<count;i++)
                        {
                              document.sendmail.sendmail[i].selected=true;
                        }
                  document.sendmail.submit();
                  return true;
            }

            function Mailadd(){
                  if (window.event.keyCode==13){
                        addmail();
                        return false;
                  }else return true;
            }

            function addmail(){
                  var mailadd,sendcount,flag1;
                  var optmail;
                     flag1=0;

                  if(document.sendmail.mailadd.value.length==0)
                        {
                              alert("Ä㻹ûÓÐÊäÈëÒªÌí¼ÓµÄEmail£¡");
                              document.sendmail.mailadd.focus();
                              flag1=1;
                        }
                  else{
                        mailadd=document.sendmail.mailadd.value;
                        if ((mailadd.indexOf("@")==-1) || (mailadd.indexOf("@")!=mailadd.lastIndexOf("@")) || mailadd.indexOf("@")==mailadd.length-1)
                        {
                              alert("ÄãÌí¼ÓµÄEmail¸ñʽ²»ÕýÈ·£¡");
                              flag1=1;
                        } else {
                              sendcount=document.sendmail.sendmail.length;

                              for(j=0;j<sendcount;j++){
                                    if(mailadd==document.sendmail.sendmail[j].value)
                                    {
                                          alert("ÄúÑ¡ÔñµÄEmailÒѾ­´æÔÚÁË£¡");
                                          flag1=1;
                                    }
                              }
                        }
                  }
                  if(flag1==0){
                        optmail=document.createElement("option");
                        optmail.text=mailadd;
                        optmail.value=mailadd;
                        document.sendmail.sendmail.add(optmail);
                        document.sendmail.mailadd.value="";
                  }
            }

            function delmail(){
                  var sendcount,flag,delcount;
                  var optmail;
                  flag=0;
                  delcount=0;
                  sendcount=document.sendmail.sendmail.length;
                  for(i=0;i<sendcount;i++){
                        if(document.sendmail.sendmail[i].selected==true){
                              flag=1;
                              for(j=i;j>0;j--)
                                    {
                                          document.sendmail.sendmail[j].value=document.sendmail.sendmail[j-1].value;
                                          document.sendmail.sendmail[j].text=document.sendmail.sendmail[j-1].text;
                                    }
                              delcount=delcount+1;
                        }
                  }
                  if (flag==0)
                        {
                              alert("ÇëÑ¡ÔñҪɾ³ýµÄEmail£¡");
                        }
                  for(i=0;i<delcount;i++)
                        {
                              document.sendmail.sendmail.remove(0);
                        }
                  for(i=0;i<document.sendmail.sendmail.length;i++)
                        {
                              document.sendmail.sendmail[i].selected=false;
                        }
            }
            //-->
            </SCRIPT>

<form style="MARGIN: 0px" action="Notify.asp?Action=send" method="post" id=sendmail name=sendmail onsubmit="initAd();return sendmail_submit();">
<TABLE cellSpacing=0 cellPadding=0 width=588 align=center border=0>
  <TBODY>
  <TR>
      <TD bgColor=#8bbee8 height=20><A tabIndex=3 href="javascript:addmail();"><IMG height=17 src="images/class/add.gif" width=59 border=0></A> <A tabIndex=5 href="javascript:delmail()"><IMG height=17 src="images/class/delete.gif" width=59 border=0></A> <INPUT id=ImageButton1 type=image src="images/class/send.gif" border=0 name=ImageButton1> <input style="WIDTH: 80px; HEIGHT: 20px" type="reset" value="ÖØÖÃ" name="reset"></TD>
   </TR>
   <TR>
       <TD width=200 height=172><SELECT ondblclick="return delmail()" style="WIDTH: 180px; HEIGHT: 146px" tabIndex=4 multiple name=sendmail></SELECT> </TD>  
   </TR>
</TABLE>
</FORM>
<%end sub

sub sendemail()

       mailto=trim(request("sendmail"))
       mailtopic=request("Subject")
       mailbody=request("Content")
            mailfrom=request("from")

            if EmailFlag=0 then
                  errmsg=errmsg+"<br>"+"<li>±¾Í¬Ñ§Â¼²»Ö§³Ö·¢ËÍÓʼþ¡£</li>"
      errorlevel="Exclamation"
      call error(errorlevel,errmsg)
                  exit sub
            elseif EmailFlag=1 then
                  call jmail_smtp()
            elseif EmailFlag=2 then
                  call Cdonts()
            elseif EmailFlag=3 then
                  call aspemail()
            elseif EmailFlag=4 then
                  call jmail_msg()
            end if

if SendMailStatus="OK" then
            stitle="Óʼþ·¢Ëͳɹ¦"
            smsg="ÄúÒѾ­³É¹¦µÄÏòÄúµÄУÓÑ·¢ËÍÁËÓʼþ¡£"
            call success(stitle,smsg)
else
            errmsg=errmsg+"<br>"+"<li>ÓÉÓÚÒÔÏÂÔ­ÒòÓʼþ·¢ËÍʧ°Ü£¡</li>"
            errmsg=errmsg+"<br>"&SendMailStatus
      errorlevel="Exclamation"
      call error(errorlevel,errmsg)
end if
end sub

'emailflag=4
sub Jmail_msg()
      dim msg
      on error resume next
      set msg = Server.CreateOBject( "JMail.Message" )
      if err then
            SendMailStatus=err.description
            err.clear
            exit sub
      end if
      msg.silent = true
      msg.Logging = true
      msg.Charset ="gb2312"
      msg.ContentType = "text/html"
      msg.From = mailfrom                        
      'msg.FromName = "Sender name"            '·¢¼þÈËÐÕÃû
      msg.RePlyTo = mailfrom      '»Ø¸´µØÖ·
      rcpt=split(mailto,",")
      for i=0 to ubound(rcpt)
            msg.AddRecipient rcpt(i) 'Ôö¼ÓÊÕ¼þÈË
      next
      msg.Subject = mailtopic                        
      msg.Body = mailbody                        
      'msg.AppendText(textYouWantToAppend)
      if SMTPAccount<>"" then      msg.MailServerUserName = SMTPAccount 'ÄúµÄÓʼþ·þÎñÆ÷µÇ¼Ãû
      if SMTPPwd<>"" then msg.MailServerPassword = SMTPPwd 'µÇ¼ÃÜÂë
      if not msg.Send(SMTPServer ) then            'SMTP·þÎñÆ÷µØÖ·
            SendMailStatus="<pre>" & msg.log & "</pre>"
      else
            SendMailStatus="OK"
      end if
      Set msg=nothing
end sub
%>
0
funby20
Asked:
funby20
  • 4
  • 4
  • 3
  • +1
2 Solutions
 
Shailesh15Commented:
try using... rcpt=split(mailto,";") insted of rcpt=split(mailto,",")

0
 
fritz_the_blankCommented:
Change this:

rcpt=split(mailto,",")


to this:

rcpt=split(mailto,";")


Fritz the Blank
0
 
funby20Author Commented:
Sorry. Typing mistake.

Previously email address split with ","

Now I use function addmail to add email address to "sendmail" and when added it, it will show:
xxxx@email.com
yyyy@??.com
and so on at Textarea name=sendmail...

Please don't edit sub Jmail_msg(). Just edit functions...
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
fritz_the_blankCommented:
Okay, I really don't know what it is that you want here. Are you saying that you would like to change the JavaScript so that it sends a comma delimited list rather than a semicolon delimited list?

FtB
0
 
Shailesh15Commented:
If you are getting the value from textbox as
xxxx@email.com yyyy@??.com etc.. use rcpt=split(mailto," ")
0
 
Shailesh15Commented:
looking at your error message"006~ASP 0177~Server.CreateObject Failed~Invalid class string ".
Are you sure that jmail component is installed properly? If you just hardcode the values are you able to send messages?
0
 
funby20Author Commented:
Shailesh15, I don't have jmail component installed. I can't test the script.

What I saw on the textarea are:
xxxx@email.com
yyyy@??.com

Don't know whether they are separated by a space or not.

If there are space between them, can u make them separated with "," after validation by java script?? It is because I don't want to change "rcpt=split(mailto,",")"
0
 
fritz_the_blankCommented:
There is a space, by default all items in a muli-select list are separated by ", "

The only way that I know of to get around that would be to take the whole list, store it to a hidden field and then query that field with your server-side functions.

Fritz the Blank
0
 
funby20Author Commented:
fritz_the_blank, since all items in a muli-select list are separated by ", "
,got any problem when spliting it with "rcpt=split(mailto,",")"??
0
 
fritz_the_blankCommented:
I still don't understand the real problem here yet (and of course, since you don't have the mail component installed, it will make it harder to pinpoint) but there is a small difference between splitting with "," and ", " as the former will leave a space at the beginning of each email address.

Two obvious choices:

1) change the split from "," to ", "
2) use the trim function on the values with leading spaces

but either of these require changing the function that you don't want to change.

FtB
0
 
Shailesh15Commented:
In addition to fritz_the_blank's comment
>> I received error msg:
>>"006~ASP 0177~Server.CreateObject Failed~Invalid class string "

>> I think the problem because of I am not split it with ";":


Your error has nothing to do with splitting of strings. This error is simple, you don't have components installed.
 If you want to change the way values are sent we need to change the page with javascript and forms.

0
 
TheKenmanCommented:
Hi funby20,

Your error is because of this line:

    set msg = Server.CreateOBject( "JMail.Message" )

The class string is the "JMail.Message" part of it.. like others have said, you need to repair/reinstall that component, or make sure any appropriate DLL's/EXE's are running.

Here's the website for JMail if you need to check anything out with them:

    http://www.dimac.net/


-Kenman
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 4
  • 4
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now