function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
iownrocknrolliownrocknroll 

Trying to create my own e-mail form in Activity History

I created a custom object called "Graduates"  Graduates in our organization are not contacts.  However we would like to be able to send an e-mail from Salesforce to the graduate and have it be tracked in the Activity History.  When we try and use the "Send An E-mail" button it only allows us to send e-mails to contacts

 

 

I was trying to setup this Java Script a Detail Page Button, I have Behavior set as "Execute Java Script" and Content Source as "OnClick JavaScript" however I am getting the following error

 

"A Problem with the OnClick JavaScript for this button or link was encountered:"

"Expected ';'"

 

Any idea how to correct this?

 

Thanks,

Jon

 

 

 private void sendEmailSample() { byte[] fileBody = new byte[1000000]; EmailFileAttachment[] fileAttachments = new EmailFileAttachment[1]; EmailFileAttachment fileAttachment = new EmailFileAttachment(); fileAttachment.setBody(fileBody); fileAttachment.setFileName("attachment"); fileAttachments[0] = fileAttachment; SingleEmailMessage[] messages = new SingleEmailMessage[1]; messages[0] = new SingleEmailMessage(); messages[0].setBccAddresses(new String[] { "jdoe@acme.com", "jdoe@merce.com" }); messages[0].setCcAddresses(new String[] { "jdoe@gmail.com", "jdoe@salesforce.com" }); messages[0].setBccSender(true); messages[0].setEmailPriority(EmailPriority.High); messages[0].setReplyTo("dcarroll@salesforce.com"); messages[0].setSaveAsActivity(true); messages[0].setSubject("This is how you use the sendEmail call."); // We can also just use an id for an implicit to address messages[0].setTargetObjectId(new ID("003D0000005OV0g")); messages[0].setUseSignature(true); messages[0].setPlainTextBody("This is the humongous body of the message."); messages[0].setFileAttachments(fileAttachments); String[] toAddresses = new String[] { "jdoe@salesforce.com" }; messages[0].setToAddresses(toAddresses); // Now send the email. try { SendEmailResult[] result = binding.sendEmail(messages); if (result[0].isSuccess()) { System.out.println("The email was sent successfully."); } else { System.out.println("The email failed to send: " + result[0].getErrors(0).getMessage()); } } catch (UnexpectedErrorFault e) { e.printStackTrace(); } catch (RemoteException e) { e.printStackTrace(); } }

SuperfellSuperfell
Your code appears to be java, unfortunately, the only relationship between java & javascript is that they both have java in the name. You'll need to write javascript not java for your button. You should be able to do the same functionality via the ajax toolkit in javascript.