Page 1 of 1

Mail sent without any attachment

Posted: Wed Dec 24, 2014 10:03 pm
by ViRa
Hi all,

I'm trying to send email notification using TI process. With the help of this forum, I'm able to do so. However, the required file is not getting attached. I need your assistance in helping me resolve this issue. Thanks a lot for your time and efforts.

Prolog : I have the code to fetch for latest log file -

Code: Select all

Lastfile = '';
s_TimeStamp = TimSt (Now, '\Y\m\d');

logfile = WildcardFileSearch( 'E:\Program Files\Cognos TM1\DataServers\TM1Data\ForDemo_Log\TM1ProcessError_'|s_TimeStamp|'*.log', lastfile);

WHILE ( logfile @<> '' );
Lastfile = logfile;
logfile = WildcardFileSearch( 'E:\Program Files\Cognos TM1\DataServers\TM1Data\ForDemo_Log\TM1ProcessError_'|s_TimeStamp|'*.log', lastfile);
END;

pAttachFile = logfile;
Epilog: I have the required vb script in place that send across email -

Code: Select all

IF( pAttachFile @<> ' ' );
arguments = 'CScript "E:\Program Files\Cognos TM1\DataServers\TM1Data\ForDemo\sendMailOther.vbs"  '|sSMTPSvr |' ' | sSender | ' "'|pRecipient|'" "'|pSubject|'" "'
| sFileName | '" "' | pAttachFile | '"';
ELSE;
arguments = 'CScript "E:\Program Files\Cognos TM1\DataServers\TM1Data\ForDemo\sendMailOther.vbs" '|sSMTPSvr |' ' | sSender | ' "'|pRecipient|'" "'|pSubject|'" "'
| sFileName | '" "' | pAttachFile | '"';
ENDIF;


EXECUTECOMMAND(arguments ,1);
When I run this process, email is sent but the file is not getting attached. However, if I hardcode the required file (with its location) it goes through.

Please advice as I have tried tweaking the code several times.

Thanks again and happy holidays!

Re: Mail sent without any attachment

Posted: Mon Dec 29, 2014 5:56 pm
by ViRa
Hi all,

Can somebody please assist me with the query?

Thanks

Re: Mail sent without any attachment

Posted: Mon Dec 29, 2014 6:16 pm
by digger
I think that your issue would be in the VBS file.

Re: Mail sent without any attachment

Posted: Mon Dec 29, 2014 7:28 pm
by tomok
I suggest you modify your code to do an ASCIIOutput of the variable "arguments" and make sure the string you are creating is actually going to do what you intend it to. 99% chance it isn't correc now and once you actually see what you've got in that variable it will jump and bite you as to what you're doing wrong.

Re: Mail sent without any attachment

Posted: Mon Dec 29, 2014 10:21 pm
by ViRa
Thanks Digger for your reply.

Thanks Tom. I did an ASCIIOUTPUT and found that pAttachFile was blank. I modified Prolog now as below and did ASCIIOUTPUT. The pAttachFile variable now shows the log file I require however this time the email is not getting triggered. Could you please guide me?

Code: Select all

#Capture the last file in the directory
Lastfile =  'TM1ProcessError_20141229163828_Load EDI Cube.log'; 

logfile = WildcardFileSearch( 'E:\Program Files\Cognos TM1\DataServers\TM1Data\ForDemo_Log\TM1ProcessError_'|s_TimeStamp|'*.log', Lastfile);

pAttachFile = logfile;
ASCII/O
ASCII/O
ASCIIFile.JPG (25.34 KiB) Viewed 5611 times

Re: Mail sent without any attachment

Posted: Tue Dec 30, 2014 12:38 am
by tomok
I see the name of the file you are trying to attach but I don't see the path. How is the email program going to be able to attach a file to an email if it doesn't know where to find it? When you store files on a computer the name of the file is only half the equation. You always need the path to where it is stored. Have you tried executing the email program without executing it through a TI, using the string produced in the "arguments" variable, to see if it works. That's the whole purpose of doing an ASCIIOutput so you can execute without doing a TI. If it won't work running manually how's it going to work in a TI?

Re: Mail sent without any attachment

Posted: Tue Dec 30, 2014 10:52 pm
by ViRa
Thanks Tom, I modified the code to provide the path for the log files and the email triggered successfully with all the required log files as attachments.

Thanks for your time and help.