Code (sometimes!) not working to set INetSendTo

Hi,An application we use requires that the INetSendTo field be set in emails.

The application imports Lotus Notes emails into another application…

When I use the code below it (always) works like this:

Whatever email address is in the SendTo field is essentially copied into the INetSendTo field. Internal email address’s are handled by a lookup and a prompt box if it fails.

For our user though, it doesn’t set the INetSendTo.

I looked on their PC, and what seemed to be happening was it made the change to the email (in sent items) but did not ‘save’ it; thus I posted on here before, and decided to add the FileSave line…but it still doesn’t work for them.

ViewName:=@ViewTitle ;

ViewNameT:=@Text(ViewName);

@If(ViewName!=“($Sent)”;

@Do(

@Prompt([Ok];“Sorry”;“You can only use this button from the Sent Items View. You are in the " + ViewNameT + " View. You will now be navigated to Sent Items, where you need to navigate to the email you wish to import.”);

@Command( [OpenView] ; “($Sent)” );

@Return(“”));

“”);

@If(INetSendTo!=“.”;“”;

@Do(

@SetField(“INetSendTo”; SendTo)));

@If(INetCopyTo!=“.”;“”;

@Do(

@SetField(“INetCopyTo”; CopyTo)));

FIELD SendTo:=SendTo;

n := 1;

@While(n <= @Elements(SendTo);

database := @Subset(@DbName; -1);

server := @Name([CN]; @Subset(@DbName; 1));

noteslookup:=@If(server=“”;

@DbLookup(“Notes”:“”; “”:NAMES.nsf;“People”;@Name([CN];SendTo[n]);“InternetAddress”);

@DbLookup(“Notes”:“”;“12345F7E:1234567B0”;“($NamesFieldLookup)”; @Name([CN];SendTo[n]);“InternetAddress”));

GetFirstName:=@Left(SendTo[n];4);

FirstLetter:=@LowerCase(@Text(@Right(GetFirstName;1 )));

Surname:=@LowerCase(@RightBack(@Name([CN];SendTo[n]);" "));

@If(@Contains(SendTo[n];“>”);

@Set(“Trimmed”;@MiddleBack(SendTo[n]; “>” ; “<” ));

“”);

Addr821:=@If(@Contains(SendTo[n];“CN=”);

@If(!@IsError(noteslookup);

noteslookup;

@Prompt([OkCancelEdit]; “Sorry! We could not find the relevant email address,”; “Please enter the correct address in the box below. We have made a suggestion for you, which needs to be changed to the correct address”; “” + FirstLetter +Surname+ “@companyname.com”));

@Name([Address821];SendTo[n]));

ABSendTo:=@If(@Contains(Addr821;"@companyname.com");Addr821;INetSendTo[n]);

@If(@Contains(Addr821;"@companyname.com");

@Set(“tempvar”;tempvar + “;” + ABSendTo);

“”);

n := n + 1);

@If(@Contains(Addr821;"@companyname.com");

@SetField(“INetSendTo”;@Explode(tempvar));

“”);

@If(Trimmed!=“”;

@SetField(“INetSendTo”;@Explode(Trimmed));“”);

@Command([FileSave]);

@Prompt([Ok];“Thank You " + @Text(@Left(@Name([CN];@UserName);” ")) + “.”; “Your email is now ready to be imported into the other Application.”)