Search code examples
lotusscriptlotus

Send Email using automate lotus script Agent (Is it possible to change the sender not a agent signer)


Notes ID:

PCSAdmin LSBSAdmin

Question: I have an agent of automate sending mail. Can we edit sender become other person not the person who signed an Agent?

Case:

  1. Currently, the agent is signed by [PCSAdmin]. So it will always send out by the person call "PCSAdmin"
  2. I want to change to another account[LSBSAdmin] send out the email, can we edit the script of sender? or must signed the agent with [LSBSAdmin]?

Lotus script

    Dim maildoc As NotesDocument
    Dim body As NotesMIMEEntity, header As NotesMIMEHeader, stream As NotesStream
    Dim child As NotesMIMEEntity
    Set stream = s.Createstream()
    s.Convertmime = False
    Set maildoc = db.Createdocument()
    maildoc.Form = "Memo"
    Set body = maildoc.Createmimeentity
    Set header = body.Createheader("Subject")
    Call header.Setheaderval("NOTIFICATION Email")
    Set header = body.Createheader("To")        '   Send to/to
    Call header.Setheaderval("personname")
    Set header = body.Createheader("CopyTo")    '   Copy To/cc
    Call header.Setheaderval("Personname")
    Call stream.Writetext(|<html><body>|)

    Call stream.Writetext(|<b>Dear | + lsdoc.Getitemvalue("Name")(0) + |,</b><br>|)
    Call stream.Writetext(|<p>|+ "Attached herewith is the FORM for Application for Renewal of application <b>"+ sadoc.name(0)+|</b>.</p>|)     
    Call stream.Writetext(|<p>| + "Please complete the FORM and send by email to <b>"+MailAddress+"</b>" +_
             ", with the subject '<b>RENEWAL Application</b>'" + |</p>|)
    Call stream.Writetext(|<p> Thank you </p>|)
    Call stream.Writetext(|<p> </p>|)
    Call stream.Writetext(|Secretary<br>|)
    Call stream.Writetext(|Company<br>|)
    Call stream.Writetext(|<em>(No signature is required on this computer generated document)</em><br>|)
    Call stream.Writetext(|</body></html>|)
    Set child = body.Createchildentity()
    Call child.Setcontentfromtext(stream, "text/HTML;charset=iso-8859-1", ENC_NONE)
    Call stream.Close()
    Call stream.Truncate()
Set child = body.Createchildentity()
    Set header = child.Createheader("Content-Type")
    Call header.Setheaderval("multipart/mixed")
    Set header = child.Createheader("Content-Disposition")
    Call header.Setheaderval(|attachment; filename="| + xlfilename + |"|)
    Set header = child.Createheader("Content-ID")
    Call header.Setheaderval(|"| + xlfilename + |"|)
    Set stream = s.Createstream()
    If Not stream.Open(template, "binary") Then
        Print "Unable to open " + template
    End If
    If stream.Bytes = 0 Then
    Print template + " has no content"
    End If
    Call child.Setcontentfrombytes(stream, "application/vnd.ms-excel", ENC_IDENTITY_BINARY)
    Call stream.Close()
    Call stream.Truncate()
    Call maildoc.Send(False)
    Print "Email sent"  
    s.Convertmime = True

Solution

  • See my answers to this earlier question and to this question, too, and Knut's answer to yet another question.

    The best method that is supported by IBM is to use the Principal field, but it doesn't completely hide the sender identity. If you need to do that, you will need to write the message directly to the mail.box file instead of using the NotesDocument.Send() method. There's a link to Karl-Henry Martinsson's script for this in Knut's answer.

    Note that searching here before asking would have been a good idea.