SentBy := @If(Principal = ""; From; Principal);
Who := @If(DeliveredDate != "" | SendTo = ""; SentBy; @Subset(SendTo; 1));
CN1 := @Trim(@Name([CN]; Who));
CN2 := @Left(@Right(Who;"/DDA:");"/" );
CN := @If(@Contains(Who;"/DDA:");CN2;@Contains(@Right(Who;"@");">") & CN1="";@Trim(Who);CN1);
G := @If(CN = ""; @Trim(@If(DeliveredDate != "" | SendTo = ""; @Name([G]; SentBy); @Name([G]; @Subset(SendTo; 1)))); "");
S := @If(CN = ""; @Trim(@If(DeliveredDate != "" | SendTo = ""; @Name([S]; SentBy); @Name([S]; @Subset(SendTo; 1)))); "");
Person := @If(CN != ""; CN; G != ""; G + " " + S; S != ""; S; @Trim(X400FreeForm));
Person2 := @If(@Left(Person;1)="\"" & @Right(Person;1)="\""; @LeftBack(@RightBack(Person;1);1); Person);
@If(Form = "Delivery Report" : "NonDelivery Report" : "Trace Report" : "Quota Report"; "Mail Router"; Person2)