Beckhoff SMTP

P

Thread Starter

PetePete

1) Program is running locally on a pc with twincat installed and running.

2) The IO device I am using to do local test is the virtual ethernet device.

3) The program itself is made in Twincat plc control.

4) Now I have a program that I have been running locally more then once. All this seems to work.

Now comes the problem. The program compiles without any error. So library,.....are all OK. I have added the function block FB_SMTPV2 for sending emails from the plc.

"Here you have the complete code = copy from infosys"
I have replaced all the private stuff with XXXX. When I run this program I get the error coming from the function block 1798 which is an ADS Error something to do with parameter values.

What could be the problem? Again all this is working locally on 1 pc and there is nothing connected to the pc itself.

PROGRAM EMAIL
VAR
fb_smtp1 :FB_SmtpV2 ;
bSend : BOOL;
bBusy : BOOL;
bError : BOOL;
nErrID : UDINT;
Zeit: TON;
bIn: BOOL;
msg: STRING[254];
bytemsg: ARRAY [0..511999] OF BYTE;
cbWrite: UDINT;
i: INT;
init: BOOL := FALSE;
sUsername: STRING;
sPassword: STRING;
END_VAR

Zeit(
IN:= bIn,
PT:= t#10S,
Q=> bSend,
ET=> );
IF NOT init THEN
cbWrite := MEMCPY(ADR(bytemsg), ADR(msg), LEN(msg));
i:=0;
FOR i := 0 TO 254 DO
msg :=CONCAT(msg, 'X');
END_FOR
FOR i := 0 TO 1960 DO
cbWrite := cbWrite + MEMCPY(ADR(bytemsg) + cbWrite, ADR(msg), LEN(msg)-1);
END_FOR
init := TRUE;
END_IF
fb_smtp1(
sNetId:= '192.168.2.112.1.1',
sSmtpServer:= 'Here I used the same SMTP outgoing server as configured in my outlook',
sUsername := 'XXXXXX',
sPassword := 'XXXXXX',
nAuth:=2,
sFrom:= 'From me',
sTo:= '[email protected] ,
sCc:= '' ,
sBcc:= '' ,
sSubject:= 'TcSmtp Service Test',
pMessage:= ADR(bytemsg) ,
cbMessage:= cbWrite,
bExecute:= bSend,
tTimeout:= t#20s,
bBusy=> bBusy,
bError=> bError,
nErrId=> nErrID
);
IF bBusy = TRUE THEN
bIn:= FALSE;
ELSIF bBusy = FALSE THEN
bIn:= TRUE;
END_IF
 
Top