Run on Behalf of User not Recorded as the Sender of email

Hey Kind Folks!

I am working with a LotusScript Agent that is run on Behalf of a Server Admin group (Set up through the agent’s properties), since our regular users should not have access to that Agent.

An email is to be sent when users click on a button, so we specify the Admin group as the Sender within the code. But when a user does click that button on the App’s form, and in turns fires that Agent to send the email, the email received in our Inbox states the user sent that email. We were expecting the sender (Admin Group) specified in the Agent to be shown as the Sender.

I suspect, Lotus Notes is picking up the user in session and using that info as the sender of that email. I am not sure if this is an accurate assumption.

An excerpt of the code is below.

'Create Email Message that includes link to current document and send out

Set MailDoc = DB.CreateDocument

MailDoc.Form = "Memo"

MailDoc.ExpandPersonalGroups = "0"

MailDoc.Principal = "ThisAdminGroup"

MailDoc.SentBy = "ThisAdminGroup"

MailDoc.DisplaySent = "ThisAdminGroup"

What are your thoughts?

Köll

Subject: create in mail.box or run scheduled

You are correct. Since the user is kicking off the agent, it is overwriting the sender fields. There are two alternatives, if you want to set the sender to a different name:1. Do not call the send function. Instead create the message document in the mail.box (not current db). Upon Save in the mail.box, it will be sent with the sender you specified.

  1. Save the message document in the current database, and have a scheduled agent do the send.

Subject: Attempting mail.box

Hi Maria!

Truly appreciate your response, glad that there is an option to handle this.

You have a nice week-end, thanks!

Köll

Subject: Mail.Box Attempted and is successful, but…

… in testing it, I noticed that while the message is saved with the Sender I set up, when the user actually does the message Send, s/he will be recorded as the Sender…

Here is code I followed to guide me, I did not write it, will try to grab the URL as reference. I merely changed what I neeeded there




Sub Click(Source As Button)

	Dim s As New NotesSession

	Dim  Subject As String, SendTo As String

	Dim Sender As String, SenderN As String

'the address you want the mail to appear to be from

	Sender = "SERVER Production <SERVER Production>"

	SenderN = "SERVER Production <SERVER Production>"

	

	subject = "You are saving this email (Send from Inbox)"

	SendTo = "me@where.the.wild.things.are.us"

	Dim DBMailBox As New NotesDatabase("WhatAGreatServerName", "mail.box")

	Dim mail As New NotesDocument( DBMailBox )

	s.ConvertMIME = False ' Do not convert MIME to rich text			

	Dim body As NotesMIMEEntity

	Dim header As NotesMIMEHeader

	Dim stream As NotesStream

	Dim child As NotesMIMEEntity

	Set stream = s.CreateStream

	Set body = mail.CreateMIMEEntity

	Set header = body.CreateHeader({MIME-Version})

	Call header.SetHeaderVal("1.0")

	Set header = body.CreateHeader("Content-Type")

	Call header.SetHeaderValAndParams({multipart/alternative;boundary="=NextPart_="})

'Add the to field

	Set header = body.CreateHeader("To")

	Call header.SetHeaderVal(SendTo)

	

'Add Subject Line

	Set header = body.CreateHeader("Subject")

	Call header.SetHeaderVal(subject)

	

'Add the body of the message

	Set child = body.CreateChildEntity

	

	Call stream.WriteText("<p>")

	Call stream.WriteText("<font face=Verdana color=#0288C1 size=3>")

	Call stream.WriteText(|<div class="headerlogo">|)

'If you are referencing any external files, images, javascript, you must use a fully qualified URL/Path

	Call stream.WriteText (|<img src="http://WhatAGreatServerName/develop/BlackberryBulletinBoard.nsf/mylogo.gif" alt="SomeLogo">|)

	Call stream.WriteText(|</div></font>|)

	Call stream.WriteText(|...some more HTML |)

	

	Call child.setContentFromText(stream, {text/html;charset="iso-8859-1"}, ENC_NONE)

	Call stream.Truncate 'Not sure if I need this

	Call stream.Close

	Call mail.CloseMIMEEntities(True)

	Call mail.replaceItemValue("Form", "Memo")

	Call mail.replaceItemValue("Recipients", SendTo)

	Call mail.replaceItemValue( "From", SenderN )

	Call mail.replaceItemValue( "InetFrom", Sender )

	

	'added SentBy coordinates

     '@author: Köll S. Cherizard

	'@version 2011.11.22.2.54.PM

	Call mail.replaceItemValue("Principal", "SERVER Production")

	Call mail.replaceItemValue("SentBy", "SERVER Production")

	Call mail.replaceItemValue("DisplaySent", "SERVER Production")

	

	'MailDoc.SentBy = "SERVER Production"

	'MailDoc.DisplaySent = "SERVER Production"

	

	

'Since we created the mail in the mail.box, we just need to save it, not send it!

	Call mail.Save(True,False)

	s.ConvertMIME = True ' Restore conversion

	

End Sub

Thanks again for your help. This may be the best option.

Update: I just added Send instead of Save thus to send the mail straight away, it worked but I got some pop ups, if I could rid of the those, we should be good. Here’s what pops up:

(1)You have requested to sign this Internet message, but your current ID does not contain “Certificate”, “This that and the other” … then OK/CANCEL options

(2)Type mismatched on external name: UIMEMODOCUMENT

(3)A stored form cannot contain computer forms

(4)Variant dopes not contain an object

Scheduling probably will not fly for this item.

Can this be helped, sounds like it wants a legal email address and cannot use the group name SERVER Production.

What are your thoughts?