String sRecipientEmail, String sRecipientUuid,
String sSubject, String sBody, String sDocId)
throws RuntimeException, NullPointerException, NotYetConnectedException, DmsException, NotEnoughRightsException, IOException, MessagingException, ElementNotFoundException {
Log.out.debug("Begin Messages.notify("+sSenderDisplayName+","+sSenderEmail+","+sSenderUuid+","+sRecipientEmail+","+sRecipientUuid+","+sSubject+","+sDocId+")");
if (sDocId==null) sDocId = "";
Dms oDms = oSes.getDms();
Message m = new Message();
m.setDocument(oDms.newDocument(oDms.getDocumentType("Message"), top(oSes).getDocument()));
m.put("thread_id", Gadgets.generateUUID());
m.put("sent_date", new Date());
m.put("sender_displayname", sSenderDisplayName);
m.put("sender_email", sSenderEmail);
if (sSenderUuid!=null) if (sSenderUuid.length()>0) m.put("sender_id", sSenderUuid);
m.put("recipient_email", sRecipientEmail);
if (sRecipientUuid!=null) if (sRecipientUuid.length()>0) m.put("recipient_id", sRecipientUuid);
m.put("message_subject", sSubject);
m.put("message_body", sBody);
m.put("is_archived", "0");
if (sDocId.length()>0) {
m.put("message_type", "incident");
m.put("related_document", sDocId);
m.save(oSes);
sendEmail(sSubject, sSenderDisplayName, sSenderEmail,new String[] {sRecipientEmail},sBody,oDms.getDocument(sDocId).type().name(),sDocId);
} else {
m.put("message_type", "notification");
m.save(oSes);
sendEmail(sSubject, sSenderDisplayName, sSenderEmail,new String[] {sRecipientEmail},sBody,null,null);
}