A simple answer may be to truncate the &USER variable into an 8-character variable.
Code
A simple answer may be to truncate the &USER variable into an 8-character variable.
Code
I was hoping to be able to do it without having to resort to something like that but... The operators are supposed to limit user profiles to 8 characters but this isn't always the case, such as with some old profiles.
I suppose your limited to the 8 if you have to use SNDDST. Regarding the operators creating user profiles, there is an exit point to the CRTUSRPRF command that you could employ to enforce your 8-character limit.
The 8-character limit is a misnomer. The User ID portion of the User ID/Address combination can be any value. After you assign the user profile name & email address to the directory entry, obtain the email address by querying the tables qatmsmtpa and qaokp01a for that user profile.
The problem I'm having is identifying the correct user id for the the user profile currently signed on. The Snddst needs to be sent to the user id, but the only information I have is the user profile
Since you've already established the profiles longer than eight characters, could you make the ID the profile dropping the last two characters (assuming you have not exceeded ten characters)? At least, the sort would be simple. You may want to make it a policy for the operator's that accounts are to be no longer than eight characters using naming standards unique to the user. We use the employee number proceeded with a letter (same letter for all accounts). I know many companies include the last name in the account and when the last name changes either a new account needs to be created or the user must continue using their previous name.
Could you create a file, say in QTEMP, using the DSPDIRE command to a *OUTFILE, then use the value in the WOSDDEN field found in the resulting file rather than the value in the WODUSRP field?
qatmsmtpa, qaokp01a. Join them by userid & address and you can get what you want for any as/400 user profile---the email address or USER ID/ADDRESS.
If user profile is 10 characters (ABCDEABCDE), enter first 8 (ABCDEABC) characters into WRKDIRE's User ID. If duplicate found change last character to a digit. In SNDDST, use "Internet Recipient" parameter: e.g. ABCDEABCDE@mycompany.com instead of the "Recipient:User ID Address" parameter. Now all you have to do is use RTVJOBA to get User ID (i.e. profile)
I wound up writing a CL program that displays the directory entries for the specified user profile to an output file, then reads the output file. It returns the user/address combination that you need for SNDDST.
Code