We all know that you can spoof the email address of an email sent by LotusScript. You just set the Principal field. Right? Well, what if it doesn't work as expected?
I've always taken it for granted that Principal fields work. Until today that is, when I had some real problems getting it to work. Off to the forum I went to try the near-impossible task of tracking down the Agent FAQ Julie Thingymebob is always referring to. I finally found the article on troubleshooting agents. In it, it says there are three ways to specify the Principal field:
- doc.Principal="Joe User/Org@NotesDomain"
Where Joe User/Org has a Person record with an InternetAddress of your choosing. (Note that the string @NotesDomain must be present.)
- doc.Principal="CN=Joe User/O=Org"
Where Joe User/Org has a Person record with an InternetAddress of your choosing.
- doc.Principal=User@acme.org@NotesDomain <mailto:User@acem.org@NotesDomain>
(Note that the string @NotesDomain must be present.)
If you are having trouble getting Principal to work this should help. Well, it would help if there weren't such obvious errors in it. Take a look at number three. Apart from the typo it should be obvious to see that the string isn't marked as a string and so would in fact cause an error. Then there's the mailto: bit. I'm not sure what that bits about but I'm pretty sure it shouldn't be there. The correct line should be:
doc.Principal="User Name <User@acme.org@NotesDomain>"
Note that the @NotesDomain gets stripped off and so mail clients see a proper SMTP-format from address of "name here <email@example.com>". However, some clients, such as Thunderbird, display both from and sender if there's a difference. TO change the apparent sender you need to change the InetFrom field. But, this shouldn't include the @NotesDomain part.
doc.Principal = "User Name <User@acme.org@NotesDomain>" doc.InetFrom = "User Name <User@acme.org>"
Note that the user and their associated email address must actually exist in order for mail routing to work properly.
While we're on the topic. Is it Principal or Principle? There seems to be confusion in the forum as to whether it's one or the other. It is of course the former, but I think Dictionary dot com can help us all (me included) understand why:
- prin ci pal
- adj. First, highest, or foremost in importance, rank, worth, or degree; chief..
- prin ci ple
- n. A basic truth, law, or assumption: the principles of democracy.
Another note: If you're using MIME headers to send HTML emails, like I was, you need to set these two fields after setting the MIME content (article on that in the pipeline).
If anybody knows of any other gotchas on this subject please add them. This post is merely some notes on what I learnt today. If I'm wrong in any way or there's more to it than this please speak up.