This tip on forwarding e-mails to another account will prevent users from getting caught in a spam loop. I used a profile to store the forwarding address. This allows the end user to control the forwarding function by simply providing or deleting a forwarding address. I used an external function Implodes from my library which provides the same functionality in LotusScript as @Implode. This is necessary if your users have a client earlier than R6. I added the addressing information to the bottom of the Body field and deleted it from the original fields.
Code
Sub Initialize
Dim session As NotesSession
Dim db As notesdatabase
Dim docMail As notesdocument
Dim doc As NotesDocument
Dim docProfile As NotesDocument
Dim cAddress As String
Dim rtItem As Variant
Set session = New NotesSession
Set db = session.CurrentDatabase
Set docProfile = db.Getprofiledocument("EmailProfile")
If docProfile Is Nothing Then Exit Sub
cAddress = docProfile.EmailForwardTo(0)
If cAddress = "" Then Exit Sub
Set doc = session.DocumentContext
Set docMail = New NotesDocument( db )
doc.CopyAllItems docMail, True
docMail.From = doc.From(0)
docMail.Principal = doc.From(0)
Set rtItem = docMail.GetFirstItem( "Body" )
rtItem.AddNewLine 2
rtItem.AppendText "From:
" & Implodes( docMail.From, "," )
rtItem.AddNewLine 1
rtItem.AppendText "To:
" & Implodes( docMail.SendTo, "," )
rtItem.AddNewLine 1
rtItem.AppendText "Cc:
" & Implodes( docMail.CopyTo, "," )
docMail.SendTo = cAddress
docMail.CopyTo = ""
docMail.BlindCopyTo = ""
docMail.Send True
End Sub
Public Function Implodes
(sVals As Variant, delim As String) As String
'Concatenate the values
of the array into a single string
On Error Goto ErrHandle
Dim tstr as String
If Isempty( sVals ) Then
Implodes = ""
Exit Function
End If
tstr = ""
If Isarray( sVals ) Then
For i = Lbound( sVals ) To Ubound(sVals)
If tstr <> "" Then tstr = tstr & delim
tstr = tstr + Cstr( sVals(i) )
Next
Else
tstr= Cstr( sVals )
End If
'Return the imploded string
Implodes = tstr
On Error Goto 0
Exit Function
ErrHandle:
...
End Function
Do you have comments on this tip? Let us know.
This tip was submitted to the SearchDomino.com tip exchange by member Gary Willert. Please let others know how useful it is via the rating scale below. Do you have a useful Notes/Domino tip or code to share? Submit it to our monthly tip contest and you could win a prize and a spot in our Hall of Fame.