Skip to main content
Hi all,

Currently, I can send email using Javascript as in the following code.

However, I need to attach files from the following table (see the pics).

Please help me to add some code so that I can attach the files to the email.

Thank you!

Add attachment to email using Javascript

The Code:

function sendSingleEmail(contactId, whatId, contents, subject)

    {

        // single mail request

        var email = new sforce.SingleEmailMessage();

        email.subject = subject;

        email.htmlBody = contents;  // fill in contents

        email.targetObjectId = contactId;   // client contact or candidate ID

        email.whatId = whatId;  // interview ID

      

        var result = sforce.connection.sendEmail([email]);

        // alert(result);

        if (result.success == true) {

            sentCount++;

        }

    }
8 answers
Loading
0/9000