Function sendMessage

  • Sends an email notification message through the LabKey Server. Message recipients and the sender must exist as valid accounts, or the current user account must have permission to send to addresses not associated with a LabKey Server account at the site-level, or an error will be thrown.

    Recipients whose accounts have been deactivated or have never been logged into will be silently dropped from the message.

    function errorHandler(errorInfo, responseObj){
    LABKEY.Utils.displayAjaxErrorResponse(responseObj, errorInfo);
    }

    function onSuccess(result){
    alert('Message sent successfully.');
    }

    LABKEY.Message.sendMessage({
    msgFrom: 'admin@test.com',
    msgSubject: 'Testing email API...',
    msgRecipients: [
    LABKEY.Message.createRecipient(LABKEY.Message.recipientType.to, 'user1@test.com'),
    LABKEY.Message.createRecipient(LABKEY.Message.recipientType.cc, 'user2@test.com'),
    LABKEY.Message.createRecipient(LABKEY.Message.recipientType.cc, 'user3@test.com'),
    LABKEY.Message.createRecipient(LABKEY.Message.recipientType.bcc, 'user4@test.com')
    ],
    msgContent: [
    LABKEY.Message.createMsgContent(LABKEY.Message.msgType.html, '<h2>This is a test message</h2>'),
    LABKEY.Message.createMsgContent(LABKEY.Message.msgType.plain, 'This is a test message')
    ],
    success: onSuccess,
    failure: errorHandler,
    });

    Parameters

    Returns XMLHttpRequest