RE: Webcentric view of changing apparent sender for email Mark I Thompson 6.Aug.01 04:05 PM a Web browser Domino Designer -- Agents All ReleasesAll Platforms
Thank you Julie Kadashevich for all your information on this topic. I'm posting
this because it would have helped me in figuring out how to get the email agents
to work as I wanted.
First, the PRINCIPAL field replaces the use of the FROM field.
We have a large number of email agents and none of the email is being sent to
Notes
users. However, most of the email recipients have an entry in our NAB and are
assigned an SMTP email address there. Also I did not test this with
canonicalized
names, because that is not relevant to environment.
I had no difficulties with the SendTo field so I won't address that here.
I did have issues with both the FROM and the REPLYTO fields. Below is what I
was
able to accomplish. I wanted the FROM field to show a name, and have an email
address
behind it. This would typically be coded "My Name <myname@mydomain.com>" I
was not
able to achieve this. So instead I compromised by displaying the persons real
email
address, instead of their name suffixed with a domain name.
In the table below Type indicates the purpose of the text being passed to the
PRINCIPAL
field. Entry is the actual text, typically from a field called EmailFrom in
our case.
FROM field:
TABLE BORDER=1 CELLPADDING=3>
<TR>
<TH>Type</TH><TH>Example Entry</TH><TH>Example Displays on Email</TH>
</TR>
<TR>
<TD>Mail-in
DB</TD><TD>RegistrationEmail</TD><TD>RegistrationEmail@ourdomain.com</TD>
</TR><TR>
<TD>Lotus Group</TD><TD>Article
Authors</TD><TD>Article_Authors@ourdomain.com</TD>
</TR><TR>
<TD>Fullname</TD><TD>Tory Volmert</TD><TD>tv@anotherdomain.com <I>(value on the
Person doc)</I></TD>
</TR><TR>
<TD>email</TD><TD>me@myisp.com</TD><TD>me@myisp.com</TD>
</TR><TR>
<TD>Bogus text</TD><TD>Auto Email</TD><TD>Auto_Email@ourdomain.com</TD>
</TR>
</TABLE>
<! Above table For Notes Readers of this document
Type Example Entry Example Displays on Email
-------- --------------- ---------------------------
Mail-in DB RegistrationEmail RegistrationEmail@ourdomain.com
Lotus Group Article Authors Article_Authors@ourdomain.com
Fullname Tory Volmert tv@anotherdomain.com (value on the
Person doc)
email me@myisp.com me@myisp.com
Bogus text Auto Email Auto_Email@ourdomain.com
-->]
For each of these I simply copied the text into the PRINCIPAL field on my
"memo" document,
except for text that had @signs in them. In those cases I appended
"@NotesDomain" onto
the text.
For the REPLYTO I wanted the same results. The "@NotesDomain" text never is
needed on the
REPLYTO field.
To get these to work properly I changed my process to lookup the email address
from the NAB.
So to put it all together here is an example WebQuerySave agent:
!-- For Notes Readers
Declarations
Dim stdEmailSendTo, stdEmailCopyTo, stdEmailBlindCopyTo, stdEmailBody
As Variant
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
On Error Goto ErrorHandler
Set doc=session.DocumentContext
Set db = session.CurrentDatabase
Sub SendEmail( SaveEmail As Variant )
Dim session As New NotesSession
Dim db As NotesDatabase
Dim email As NotesDocument
Set db = session.CurrentDatabase
Set email = New NotesDocument ( db )
email.Form = "Memo"
email.Subject = stdEmailSubject
email.Principal = stdEmailFrom
email.ReplyTo = stdEmailReplyTo
email.SendTo = stdEmailSendTo
email.CopyTo = stdEmailCopyTo
email.BlindCopyTo = stdEmailBlindCopyTo
Call email.send (False)
If SaveEmail Then
Call email.save (False, True)
End If
End Sub
Sub SetEmailFrom( eFrom As String, ReplyTo As String)
Dim emailaddress As String
If Instr(eFrom, "@") > 0 Then
stdEmailFrom = eFrom & "@NotesDomain"
Else
'look up email address on nab, if not found just copy FROM name
emailaddress = GetEmailAddress( eFrom, "names.nsf")
If emailaddress = eFrom Then
stdEmailFrom = eFrom
Else
stdEmailFrom = emailaddress & "@NotesDomain"
End If
End If
If Instr(ReplyTo, "@") > 0 Then
stdEmailReplyTo = ReplyTo
Else
'look up email address on nab, if not found just copy From
name to
emailaddress = GetEmailAddress( ReplyTo, NAB1)
If emailaddress = ReplyTo Then
stdEmailReplyTo = ReplyTo
Else
stdEmailReplyTo = emailaddress
End If
End If
End Sub
Function GetEmailAddress( EmailName As String, NAB As String) As String
Dim session As New NotesSession
Dim db As NotesDatabase
Dim NABdb As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
On Error Goto ErrorHandler
GetEmailAddress = EmailName
Set db = session.CurrentDatabase
Set NABdb = New NotesDatabase( db.server, NAB )
Set view = NABdb.GetView( "($VIMPeople)" )
Set doc = view.GetDocumentbykey(EmailName)
If Not doc Is Nothing Then
GetEmailAddress = doc.MailAddress(0)
End If
Exit Function
ErrorHandler:
Exit Function
End Function
-->
Declarations<BR>
Dim stdEmailSendTo, stdEmailCopyTo, stdEmailBlindCopyTo, stdEmailBody As
Variant<BR>
<P>
Sub Initialize<BR>
Dim session As New NotesSession<BR>
Dim db As NotesDatabase<BR>
Dim doc As NotesDocument<BR>
On Error Goto ErrorHandler <BR>
<BR>
Set doc=session.DocumentContext<BR>
Set db = session.CurrentDatabase<BR>
<BR>
Call SetEmailFrom( doc.From(0), doc.ReplyTo(0)
) <BR>
stdEmailSubject = doc.EmailSubject(0) <BR>
stdEmailSendTo = doc.GetItemValue( "SendTo" )<BR>
stdEmailCopyTo = doc.GetItemValue( "CopyTo" )<BR>
stdEmailBlindCopyTo = doc.GetItemValue(
"BlindCopyTo" )<BR>
stdEmailBody = doc.emailbody<BR>
<BR>
Call SendEmail(True)<BR>
End Sub<BR>
<P>
Sub SendEmail( SaveEmail As Variant )<BR>
Dim session As New NotesSession<BR>
Dim db As NotesDatabase<BR>
Dim email As NotesDocument<BR>
<BR>
Set db = session.CurrentDatabase<BR>
<BR>
Set email = New NotesDocument ( db )<BR>
email.Form = "Memo"<BR>
email.Subject = stdEmailSubject<BR>
email.Principal = stdEmailFrom<BR>
email.ReplyTo = stdEmailReplyTo<BR>
email.SendTo = stdEmailSendTo<BR>
email.CopyTo = stdEmailCopyTo<BR>
email.BlindCopyTo = stdEmailBlindCopyTo<BR>
<BR>
Call email.send (False)<BR>
If SaveEmail Then<BR>
Call email.save
(False, True)<BR>
End If<BR>
End Sub<BR>
<P>
Sub SetEmailFrom( eFrom As String, ReplyTo As String)<BR>
Dim emailaddress As String<BR>
<BR>
If Instr(eFrom, "@") > 0 Then<BR>
stdEmailFrom =
eFrom & "@NotesDomain"<BR>
Else<BR>
'look up email
address on nab, if not found just copy FROM name <BR>
emailaddress =
GetEmailAddress( eFrom, "names.nsf")<BR>
If emailaddress =
eFrom Then<BR>
&n
bsp; stdEmailFrom = eFrom<BR>
Else<BR>
&n
bsp; stdEmailFrom = emailaddress & "@NotesDomain"<BR>
End If<BR>
End If<BR>
<BR>
If Instr(ReplyTo, "@") > 0 Then<BR>
stdEmailReplyTo =
ReplyTo<BR>
Else<BR>
'look up email
address on nab, if not found just copy From name to <BR>
emailaddress =
GetEmailAddress( ReplyTo, NAB1)<BR>
If emailaddress =
ReplyTo Then<BR>
&n
bsp; stdEmailReplyTo = ReplyTo<BR>
Else<BR>
&n
bsp; stdEmailReplyTo = emailaddress<BR>
End If<BR>
End If<BR>
End Sub<BR>
<P>
Function GetEmailAddress( EmailName As String, NAB As String) As String<BR>
Dim session As New NotesSession<BR>
Dim db As NotesDatabase<BR>
Dim NABdb As NotesDatabase<BR>
Dim view As NotesView<BR>
Dim doc As NotesDocument<BR>
<BR>
On Error Goto ErrorHandler<BR>
<BR>
GetEmailAddress = EmailName<BR>
<BR>
Set db = session.CurrentDatabase<BR>
Set NABdb = New NotesDatabase( db.server, NAB
)<BR>
Set view = NABdb.GetView( "($VIMPeople)" )<BR>
Set doc = view.GetDocumentbykey(EmailName)<BR>
<BR>
If Not doc Is Nothing Then<BR>
GetEmailAddress =
doc.MailAddress(0)<BR>
End If<BR>
Exit Function<BR>
<BR>
ErrorHandler:<BR>
Exit Function<BR>
End Function<BR>
<!>]