Anaplan Connect Email Script

Hello Team

Greetings,

I was configuring the anaplan connect script, where right after the import of file is done, i should be able to trigger the email notification. i tried to configure the some part of the script and rest am not able to so looking ahead for the advise.

Kind Note : I have installed the SMTP.exe extension which is asked in one of the community post, whose link is "https://community.anaplan.com/t5/Best-Practices/Integrated-Error-Handling-and-Email-Notification/ta-p/20701#"

But not able to configure the from "section 3", Kindly help!

I have attached document of my script for your reference kindly guide me where i am missing

 

SCRIPT :

cls
echo on
setlocal enableextensions

REM **** SECTION #1 - SET VARIABLE VALUES ****
set /a ERRNO=0
set /a COUNT=0
set /a RETRY_COUNT=1

REM Set Anaplan Connect Variables
set AnaplanUser="example1@email.com:xxxxxxx"
set WorkspaceId="workspace ID"
set ModelId="Model ID"
set Operation=-import "Test 1.csv" -execute ^
-output ".\My Errors.txt"

REM Set Email variables
set Domain="email.com"
set Smtp="smtp.office365.com"
set User="example1@email.com"
set Pass="xxxxxxx"
set To=-t "example1@email.com" -t "example2@email.com"
set From="example1@email.com"
set Subject="Anaplan Connect Status"

REM Set other types of variables such as file path names to be used in the Anaplan Connect "Operation" command

set ServiceUrl="https://api.anaplan.com"
set AuthUrl="https://auth.anaplan.com"
set Chunksize=1

set Operation=-debug -service %ServiceUrl% -auth %AuthUrl% -workspace %WorkspaceId% -model %ModelId% -chunksize %Chunksize%


REM **** SECTION #2 - PRE ANAPLAN CONNECT COMMANDS ***
REM Use this section to perform standard batch commands or operations prior to running Anaplan Connect

set FileName="Test 1.csv"
set FilePath=""C:\Users\prateek kulkarni\OneDrive\Desktop\Informatica integration\Test 1.csv""
set ImportName="test from Test 1.csv"
set DumpName="C:\Anaplan Connect 3.0\Anaplan_dump files\Email Notification dump"

set Operation=-debug -service %ServiceUrl% -auth %AuthUrl% -workspace %WorkspaceId% -model %ModelId% -chunksize %Chunksize%
set Operation= %Operation% -file %FileName% -put %FilePath% -import %ImportName% -execute -output %DumpName%

rem *** End of settings - Do not edit below this line ***

setlocal enableextensions enabledelayedexpansion || exit /b 1
cd %~dp0
if not %AnaplanUser% == "" set Credentials=-user %AnaplanUser%
set Command=AnaplanClient.bat %Credentials% %Operation%
@Echo%Command%
cmd /c %Command%
PAUSE

REM **** SECTION #3 - ANAPLAN CONNECT COMMANDS ***

:START
REM Dynamically set logfile name based upon current date and retry count.
set LogFile="%date:~-9%-%date:~21,1%-%date:~9,1%-ANAPLAN-LOG-RUN-%COUNT%.TXT"

REM Delete prior log and error files
del .\BAT_STAT.TXT
del .\AC_API.ERR

REM Out-of-the-box Anaplan Connect code with the exception of sending output to a log file
setlocal enableextensions enabledelayedexpansion || exit /b 1
REM Change the directory to the batch file's drive, then change to its folder
cd %~dp0
if not %AnaplanUser% == "" set Credentials=-user %AnaplanUser%
set Command=.\AnaplanClient.bat %Credentials% -workspace %WorkspaceId% -model %ModelId% %Operation%
@Echo%Command%
cmd /C %Command% > .\%LogFile%

REM **** SECTION #4 - SET SEARCH CRITERIA - REPEAT @FINDSTR COMMAND AS MANY TIMES AS NEEDED ***
@findstr /c:"The file" .\%LogFile% > .\AC_API.ERR
@findstr /c:"Anaplan API" .\%LogFile% >> .\AC_API.ERR

REM Remove any 0K files produced by previous findstr commands
@for /r %%f in (*) do if %%~zf==0 del "%%f"

REM **** SECTION #5 - TRAP ERROR CONDITIONS ***
REM If the file AC_API.ERR exists then echo errors to the primary BAT_STAT log file
REM Else echo the log file to the primary BAT_STAT log file
@if exist .\AC_API.ERR (
@Echo. >> .\BAT_STAT.TXT
@Echo*** ANAPLAN CONNECT ERROR OCCURED *** >> .\BAT_STAT.TXT
@Echo-------------------------------------------------------------- >> .\BAT_STAT.TXT
type .\AC_API.ERR >> .\BAT_STAT.TXT
@Echo-------------------------------------------------------------- >> .\BAT_STAT.TXT
set Subject="ANAPLAN CONNECT ERROR OCCURED"
) else (
@Echo. >> .\BAT_STAT.TXT
@Echo*** ALL OPERATIONS COMPLETED SUCCESSFULLY *** >> .\BAT_STAT.TXT
@Echo-------------------------------------------------------------- >> .\BAT_STAT.TXT
type .\%LogFile% >> .\BAT_STAT.TXT
@Echo-------------------------------------------------------------- >> .\BAT_STAT.TXT
set Subject="ANAPLAN LOADED SUCCESSFULLY"
)

REM **** SECTION #6 - SEND EMAIL VIA MAILSEND ***
@mailsend -domain %Domain% ^
-smtp %Smtp% ^
-auth -user %User% ^
-pass %Pass% ^
%To% ^
-f %From% ^
-sub %Subject% ^
-msg-body .\BAT_STAT.TXT

REM **** SECTION #7 - DETERMINE IF A RETRY IS REQUIRED ***
@if exist .\AC_API.ERR (
@if %COUNT% lss %RETRY_COUNT% (
@set /a COUNT+=1
@Goto:START
) else (
set /a ERRNO=1
@Goto:END
)
) else (
set /a ERRNO=0
)

REM **** SECTION #8 - POST ANAPLAN CONNECT COMMANDS ***
REM Use this section to perform standard batch commands or operations after running Anaplan Connect commands


:END
exit /b %ERRNO%

 

Answers