m_essaid
11 years agoValued Contributor
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. But in some cases i have to not send any files.
I tried to modify this appeal of the mail function :
SendEmail("tester@mycompany.com", "boss@mycompany.com", "Subject", _
"Message body", "c:\File1.txt,c:\File2.txt,c:\File3.txt")
by putting '' or nil but in the first case it attach an empty file, in the second case it don't execute the script.
Any help please ?
Mehdi
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. But in some cases i have to not send any files.
I tried to modify this appeal of the mail function :
SendEmail("tester@mycompany.com", "boss@mycompany.com", "Subject", _
"Message body", "c:\File1.txt,c:\File2.txt,c:\File3.txt")
by putting '' or nil but in the first case it attach an empty file, in the second case it don't execute the script.
Any help please ?
Mehdi
- 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.