Forum Discussion

m_essaid's avatar
m_essaid
Valued Contributor
11 years ago

Using the CDO SendMail functions without attaching files

Hi, I use the following help to send a pdf : http://support.smartbear.com/viewarticle/56308/?_ga=1.182325346.417838577.1387551043#CDO It works pretty well when i have a file to attach. Bu...
  • tristaanogre's avatar
    11 years ago
    It's a little strange that the SendEmail is attempting to send an attachment if there are no files to attach.  Maybe you need to modify the SendEmail script a bit...



    Currently, in JScript, we have this section:



        for(i = 0; i < aqString.GetListLength(mAttach); i++)

          mMessage.AddAttachment(aqString.GetListItem(mAttach, i));





    It seems that, if GetListLength is 0, it will still attempt 1 iteration through the for loop (i from 0 to 0).  So, what if we put, before the for loop, some if/then logic.  Like so:



    if (aqString.GetListLength(mAttach) > 0)

    {

    for(i = 0; i < aqString.GetListLength(mAttach); i++)

          mMessage.AddAttachment(aqString.GetListItem(mAttach, i));

    }





    That way, if the mAttach parameter is empty, it won't even execute the for loop.



    See if that works for you.