1

I am developing an application to send mail to a group of user using java script from Lotus notes. we are using shared mailbox for a user.

When i trigger this mail script it is sending from my personal mailbox

Is it possible to trigger the mail from the shared mailbox?

<script>
function sendEmail()
{
    var notesDatabase;
    var notesSessiona;
    notesSessiona = new ActiveXObject("Notes.NotesSession");
    notesDatabase = notesSessiona.GETDATABASE("staralliancesupport", "");
    notesDatabase.OPENMAIL();
    var mailItem = notesDatabase.CreateDocument();
    mailItem.subject = te.value +" Outage"+" "+text11.value+tex111.value+tex11.value+tex21.value+tex31.value+tex41.value+tex51.value+tex61.value+tex71.value+tex81.value+tex91.value+" "+ text.value+" "+ tex.value+" session down"
    mailItem.sendto = "nathan.sabari@tcs.com";
    mailItem.copyto = textbox_1.value;
    mailItem.BlindCopyTo = "";
    mailItem.Body = "Dear All,\n\nNote: This e-mail is sent to Star Alliance member carrier contacts, their business partners and provider help desks.\n\nStar Alliance  would like to inform you about the "+ tex.value +" interruption between Star Alliance and-"+" "+te.value+" "+text11.value+tex111.value+tex11.value+tex21.value+tex31.value+tex41.value+tex51.value+tex61.value+tex71.value+tex81.value+tex91.value+" "+ text.value+".\n\nWe are liaising with the airline's service desk to get more information regarding this issue.\n\n--\n\nStar Alliance Support\nEmail support at: Staralliance.support@tcs.com\nTelephone contact No: +1877 292 9784\n"
    mailItem.Send (0);
}
</script>
James Z
  • 12,209
  • 10
  • 24
  • 44
don sabari
  • 1
  • 2
  • 5

1 Answers1

0

Changing the database will not change the sender. The server always puts the current username in the sender name. You need to write your message directly to the mail.box file instead of using the NotesDocument.Send() method.

See Knut's answer to an earlier question about this. It contains a link to a script by Karl-Henry Martinsson that demonstrates the technique. It's LoutsScript, though, so you're going to have to translate that script to JavaScript.

For your specific problem, the most important lines of code in Karl-Henry's LotusScript code are:

  Set mailbox = New NotesDatabase(mailservername,"mail.box")
  If mailbox.Isopen = False Then
   Print "mail.box on " & mailservername & " could not be opened"
   Exit Sub
  End If
  Set me.maildoc = New NotesDocument(mailbox)

and...

   If me.p_principal<>"" Then
     Call maildoc.ReplaceItemValue("Principal", me.p_principal)
     ' If principal is set, we want to fix so mail looks like
     ' it is coming from that address, need to set these fields
     Call maildoc.ReplaceItemValue("From", me.p_principal)
     Call maildoc.ReplaceItemValue("Sender", me.p_principal)
     Call maildoc.ReplaceItemValue("ReplyTo", me.p_principal)
     Call maildoc.ReplaceItemValue("SMTPOriginator", me.p_principal)
   End If

where me.p_principal contains the address he wants the message to come from, and...

Call maildoc.Save(True,False) ' Save in mail.box

Note that he doesn't call maildoc.Send() when he wants to control the From address. He just calls maildoc.Save(), and this works because he is saving it in the mail.box file.

Richard Schwartz
  • 14,463
  • 2
  • 23
  • 41
  • i am just a starter unable to find the answer with the above could you please elaborate sorry... – don sabari Mar 06 '18 at 06:52
  • I have extracted the important lines of code from Karl-Henry's script for you and added them to my answer. – Richard Schwartz Mar 06 '18 at 14:15
  • 1
    Take into consideration something Karl-Henry's code includes: the field PostedDate needs to have a value (usually the result of calling Now), otherwise the email will be visible in the Drafts view. – richieadler Mar 08 '18 at 18:39
  • Yes, and IIRC that also raises the point that you must save it in both mail.box and your mail file (or the shared mail file) if you want to keep a copy of the sent message. If you just save it in mail.box, that won't happen. – Richard Schwartz Mar 08 '18 at 18:42