Solved

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

Posted on 2004-04-17
12
619 Views
Last Modified: 2007-12-19
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
Comment
Question by:funby20
  • 4
  • 4
  • 3
  • +1
12 Comments
 
LVL 10

Expert Comment

by:Shailesh15
ID: 10849871
try using... rcpt=split(mailto,";") insted of rcpt=split(mailto,",")

0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 10849875
Change this:

rcpt=split(mailto,",")


to this:

rcpt=split(mailto,";")


Fritz the Blank
0
 

Author Comment

by:funby20
ID: 10849971
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
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 10849993
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
 
LVL 10

Expert Comment

by:Shailesh15
ID: 10850084
If you are getting the value from textbox as
xxxx@email.com yyyy@??.com etc.. use rcpt=split(mailto," ")
0
 
LVL 10

Expert Comment

by:Shailesh15
ID: 10850142
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:funby20
ID: 10850649
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
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 10850695
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
 

Author Comment

by:funby20
ID: 10851274
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
 
LVL 46

Accepted Solution

by:
fritz_the_blank earned 300 total points
ID: 10853519
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
 
LVL 10

Assisted Solution

by:Shailesh15
Shailesh15 earned 200 total points
ID: 10853642
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
 
LVL 7

Expert Comment

by:TheKenman
ID: 10854106
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Visual Project Bridge error 5 70
Using AJAX to call classic ASP function 4 82
SQL to update characters in table column 6 82
is this a cms? 8 32
I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now